diff options
Diffstat (limited to 'v4.0/src/DOS/DISP.ASM')
| -rw-r--r-- | v4.0/src/DOS/DISP.ASM | 579 |
1 files changed, 579 insertions, 0 deletions
diff --git a/v4.0/src/DOS/DISP.ASM b/v4.0/src/DOS/DISP.ASM new file mode 100644 index 0000000..fba9764 --- /dev/null +++ b/v4.0/src/DOS/DISP.ASM | |||
| @@ -0,0 +1,579 @@ | |||
| 1 | ; SCCSID = @(#)disp.asm 1.1 85/04/10 | ||
| 2 | ; SCCSID = @(#)disp.asm 1.1 85/04/10 | ||
| 3 | ; | ||
| 4 | ; Dispatcher code | ||
| 5 | ; | ||
| 6 | |||
| 7 | .xlist | ||
| 8 | .xcref | ||
| 9 | INCLUDE DOSSYM.INC | ||
| 10 | include dosseg.asm | ||
| 11 | .cref | ||
| 12 | .list | ||
| 13 | |||
| 14 | AsmVars <Kanji, Debug> | ||
| 15 | |||
| 16 | BREAK <Copyright notice and version> | ||
| 17 | CODE SEGMENT BYTE PUBLIC 'CODE' | ||
| 18 | |||
| 19 | |||
| 20 | I_need CurrentPDB,WORD | ||
| 21 | I_need CntCFlag,BYTE | ||
| 22 | I_need User_SS,WORD | ||
| 23 | I_need User_SP,WORD | ||
| 24 | I_need NSS,WORD | ||
| 25 | I_need NSP,WORD | ||
| 26 | I_need MaxCall,BYTE | ||
| 27 | I_need MaxCom,BYTE | ||
| 28 | I_need SaveDS,WORD | ||
| 29 | I_need SaveBX,WORD | ||
| 30 | I_need INDOS,BYTE | ||
| 31 | I_need User_ID,WORD | ||
| 32 | I_need Proc_ID,WORD | ||
| 33 | I_need AuxStack,BYTE | ||
| 34 | I_need IOSTACK,BYTE | ||
| 35 | I_need DSKSTACK,BYTE | ||
| 36 | I_need fsharing,BYTE | ||
| 37 | I_need NoSetDir,BYTE | ||
| 38 | I_need FailERR,BYTE | ||
| 39 | I_need Errormode,BYTE | ||
| 40 | I_need restore_tmp,WORD | ||
| 41 | I_need WPERR,BYTE | ||
| 42 | I_need Dispatch,WORD | ||
| 43 | I_need ConSwap,BYTE | ||
| 44 | I_need User_In_AX,WORD | ||
| 45 | I_need EXTERR_LOCUS,BYTE | ||
| 46 | I_need IdleInt,BYTE | ||
| 47 | I_need Printer_Flag,BYTE | ||
| 48 | I_need CPSWFLAG,BYTE ;AN000; | ||
| 49 | I_need CPSWSAVE,BYTE ;AN000; | ||
| 50 | I_need DISK_FULL,BYTE ;AN000; | ||
| 51 | I_need InterCon,BYTE ;AN000; | ||
| 52 | I_need BOOTDRIVE,BYTE ;AN000; | ||
| 53 | I_need EXTOPEN_ON,BYTE ;AN000; | ||
| 54 | I_need DOS34_FLAG,WORD ;AN000; | ||
| 55 | I_need ACT_PAGE,WORD ;AN000; | ||
| 56 | |||
| 57 | IF NOT IBM | ||
| 58 | I_need OEM_HANDLER,DWORD | ||
| 59 | ENDIF | ||
| 60 | |||
| 61 | IF BUFFERFLAG | ||
| 62 | I_am SETVECTFLAG,BYTE,<0> | ||
| 63 | i_need BUF_EMS_SEG_CNT,WORD ; DOS 4.00 EMS seg count ;AN000; | ||
| 64 | i_need BUF_EMS_MODE,BYTE ; DOS 4.00 EMS mode ;AN000; | ||
| 65 | i_am BUF_EMS_MAP_USER,12,<0,0,0,0,0,0,0,0,0,0,0,0> | ||
| 66 | ENDIF | ||
| 67 | |||
| 68 | ASSUME CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 69 | |||
| 70 | BREAK <System call entry points and dispatcher> | ||
| 71 | ASSUME CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 72 | |||
| 73 | BREAK <$Set_CTRL_C_Trapping -- En/Disable ^C check in dispatcher> | ||
| 74 | |||
| 75 | ; Inputs: | ||
| 76 | ; AL = 0 read ^C status | ||
| 77 | ; AL = 1 Set ^C status, DL = 0/1 for ^C off/on | ||
| 78 | ; AL = 2 Set ^C status to contents of DL. Output is old state. | ||
| 79 | ; AL = 3 Get CPSW state to DL DOS 3.4 | ||
| 80 | ; AL = 4 Set CPSW state from DL DOS 3.4 | ||
| 81 | ; AL = 5 get DOS boot drive | ||
| 82 | ; Function: | ||
| 83 | ; Enable disable ^C checking in dispatcher | ||
| 84 | ; Outputs: | ||
| 85 | ; If AL = 0 then DL = 0/1 for ^C off/on | ||
| 86 | |||
| 87 | procedure $SET_CTRL_C_TRAPPING,NEAR | ||
| 88 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 89 | OR AL,AL | ||
| 90 | JNZ Check1 | ||
| 91 | MOV DL,CntCFlag | ||
| 92 | IRET | ||
| 93 | Check1: | ||
| 94 | CMP AL,2 | ||
| 95 | JA CPSWchk ;AN000; | ||
| 96 | JZ SetAndRet | ||
| 97 | PUSH DX | ||
| 98 | AND DL,01h | ||
| 99 | MOV [CNTCFLAG],DL | ||
| 100 | POP DX | ||
| 101 | IRET | ||
| 102 | SetAndRet: | ||
| 103 | AND DL,01h | ||
| 104 | XCHG CntCFlag,DL | ||
| 105 | IRET | ||
| 106 | BadVal: | ||
| 107 | MOV AL,0FFH | ||
| 108 | IRET | ||
| 109 | ;; DOS 4.00 File Tagging | ||
| 110 | |||
| 111 | CPSWchk: ;AN000; | ||
| 112 | ; PUSH AX ;AN000;;FT. | ||
| 113 | ; MOV AL,[CPSWSAVE] ;AN000;;FT. DOS 3.4 | ||
| 114 | ; MOV [CPSWFLAG],AL ;AN000;;FT. DOS 3.4 in case ABORT | ||
| 115 | ; POP AX ;AN000;;FT. | ||
| 116 | CMP AL,3 ;AN000;;FT get CPSW state ? | ||
| 117 | JNZ CPSWset ;AN000;;FT. no | ||
| 118 | ; MOV DL,CPSWFLAG ;AN000;;FT. return CPSW state | ||
| 119 | IRET ;AN000; | ||
| 120 | CPSWset: ;AN000; | ||
| 121 | CMP AL,4 ;AN000;;FT. set CPSW state ? | ||
| 122 | JA QueryDOSboot ;AN000;;FT. check query dos boot drive | ||
| 123 | ; PUSH AX ;AN000;;FT. | ||
| 124 | ; CallInstall NLSInstall,NLSFUNC,0 ;AN000;;FT. NLSFUNC installed ? | ||
| 125 | ; CMP AL,0FFH ;AN000;;FT. | ||
| 126 | ; POP AX ;AN000;;FT. | ||
| 127 | ; JNZ BadVal ;AN000;;FT. not loaded, therefore ignore | ||
| 128 | ;;;; AND DL,01H ;AN000;;FT. only 0 or 1 | ||
| 129 | ;;;; MOV [CPSWFLAG],DL ;AN000;;FT. set the flag | ||
| 130 | ;;;; MOV [CPSWSAVE],DL ;AN000;;FT. save one copy | ||
| 131 | IRET ;AN000;;FT. | ||
| 132 | QueryDOSboot: ;AN000; | ||
| 133 | CMP AL,5 ;AN000;MS. | ||
| 134 | JA BadVal ;AN000;MS. | ||
| 135 | MOV DL,[BOOTDRIVE] ;AN000;;MS. put boot drive in DL | ||
| 136 | IRET ;AN000;;MS. | ||
| 137 | |||
| 138 | |||
| 139 | ;; DOS 4.00 File Tagging | ||
| 140 | |||
| 141 | EndProc $SET_CTRL_C_TRAPPING | ||
| 142 | |||
| 143 | BREAK <$Get_current_PDB -- Set/Get PDB value> | ||
| 144 | ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----; | ||
| 145 | ; C A V E A T P R O G R A M M E R ; | ||
| 146 | ; ; | ||
| 147 | ; The following two routines are dispatched to directly with ints disabled | ||
| 148 | ; immediately after the int 21h entry. no DIS state is set. | ||
| 149 | ; | ||
| 150 | ; $Set_current_PDB takes BX and sets it to be the current process | ||
| 151 | ; *** THIS FUNCTION CALL IS SUBJECT TO CHANGE!!! *** | ||
| 152 | ; | ||
| 153 | procedure $SET_CURRENT_PDB,NEAR | ||
| 154 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 155 | MOV [CurrentPDB],BX | ||
| 156 | IRET | ||
| 157 | EndProc $SET_CURRENT_PDB | ||
| 158 | |||
| 159 | ; | ||
| 160 | ; $get_current_PDB returns in BX the current process | ||
| 161 | ; *** THIS FUNCTION CALL IS SUBJECT TO CHANGE!!! *** | ||
| 162 | ; | ||
| 163 | procedure $GET_CURRENT_PDB,NEAR | ||
| 164 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 165 | MOV BX,[CurrentPDB] | ||
| 166 | IRET | ||
| 167 | EndProc $GET_CURRENT_PDB | ||
| 168 | ; C A V E A T P R O G R A M M E R ; | ||
| 169 | ; ; | ||
| 170 | ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----; | ||
| 171 | |||
| 172 | ; | ||
| 173 | ; Sets the Printer Flag to whatever is in AL. | ||
| 174 | ; NOTE: THIS PROCEDURE IS SUBJECT TO CHANGE!!! | ||
| 175 | ; | ||
| 176 | Procedure $Set_Printer_Flag | ||
| 177 | ASSUME DS:NOTHING, ES:NOTHING, SS:NOTHING | ||
| 178 | mov [Printer_Flag],al | ||
| 179 | IRET | ||
| 180 | EndProc $Set_Printer_Flag | ||
| 181 | |||
| 182 | procedure SYSTEM_CALL,NEAR | ||
| 183 | ; | ||
| 184 | ; The Quit entry point is where all INT 20h's come from. These are old- style | ||
| 185 | ; exit system calls. The CS of the caller indicates which Process is dying. | ||
| 186 | ; The error code is presumed to be 0. We simulate an ABORT system call. | ||
| 187 | ; | ||
| 188 | entry QUIT | ||
| 189 | MOV AH,0 | ||
| 190 | JMP SHORT SAVREGS | ||
| 191 | ; | ||
| 192 | ; The system call in AH is out of the range that we know how to handle. We | ||
| 193 | ; arbitrarily set the contents of AL to 0 and IRET. Note that we CANNOT set | ||
| 194 | ; the carry flag to indicate an error as this may break some programs | ||
| 195 | ; compatability. | ||
| 196 | ; | ||
| 197 | BADCALL: | ||
| 198 | MOV AL,0 | ||
| 199 | entry IRETT | ||
| 200 | IRET | ||
| 201 | ; | ||
| 202 | ; An alternative method of entering the system is to perform a CALL 5 in the | ||
| 203 | ; program segment prefix with the contents of CL indicating what system call | ||
| 204 | ; the user would like. A subset of the possible system calls is allowed here; | ||
| 205 | ; only the CPM-compatible calls may get dispatched. | ||
| 206 | ; | ||
| 207 | entry CALL_ENTRY ; System call entry point and dispatcher | ||
| 208 | POP AX ; IP from the long call at 5 | ||
| 209 | POP AX ; Segment from the long call at 5 | ||
| 210 | POP [User_SP] ; IP from the CALL 5 | ||
| 211 | ; | ||
| 212 | ; Re order the stack to simulate an interrupt 21. | ||
| 213 | ; | ||
| 214 | PUSHF ; Start re-ordering the stack | ||
| 215 | CLI | ||
| 216 | PUSH AX ; Save segment | ||
| 217 | PUSH [User_SP] ; Stack now ordered as if INT had been used | ||
| 218 | CMP CL,MAXCALL ; This entry point doesn't get as many calls | ||
| 219 | JA BADCALL | ||
| 220 | MOV AH,CL | ||
| 221 | JMP SHORT SavRegs | ||
| 222 | ; | ||
| 223 | ; This is the normal INT 21 entry point. We first perform a quick test to see | ||
| 224 | ; if we need to perform expensive DOS-entry functions. Certain system calls | ||
| 225 | ; are done without interrupts being enabled. | ||
| 226 | ; | ||
| 227 | |||
| 228 | entry COMMAND ; Interrupt call entry point (INT 21H) | ||
| 229 | |||
| 230 | IF NOT IBM | ||
| 231 | CMP AH,SET_OEM_HANDLER | ||
| 232 | JB NOTOEM | ||
| 233 | JMP $SET_OEM_HANDLER | ||
| 234 | NOTOEM: | ||
| 235 | ENDIF | ||
| 236 | |||
| 237 | CMP AH,MAXCOM | ||
| 238 | JA BadCall | ||
| 239 | |||
| 240 | ; | ||
| 241 | ; The following set of calls are issued by the server at *arbitrary* times | ||
| 242 | ; and, therefore, must be executed on the user's entry stack and executed with | ||
| 243 | ; interrupts off. | ||
| 244 | ; | ||
| 245 | SAVREGS: | ||
| 246 | CMP AH,GET_CURRENT_PDB | ||
| 247 | JZ $GET_CURRENT_PDB | ||
| 248 | CMP AH,GetCurrentPSP | ||
| 249 | JZ $GET_CURRENT_PDB | ||
| 250 | CMP AH,SET_CURRENT_PDB | ||
| 251 | JZ $SET_CURRENT_PDB | ||
| 252 | CMP AH,Set_CTRL_C_Trapping | ||
| 253 | JNZ chkprt | ||
| 254 | JMP $Set_CTRL_C_Trapping | ||
| 255 | chkprt: | ||
| 256 | CMP AH,SET_PRINTER_FLAG | ||
| 257 | JZ $Set_Printer_Flag | ||
| 258 | ; | ||
| 259 | ; Preserve all user's registers on his own stack. | ||
| 260 | ; | ||
| 261 | CALL save_world | ||
| 262 | MOV [SaveDS],DS | ||
| 263 | MOV [SaveBX],BX | ||
| 264 | MOV BX,CS | ||
| 265 | MOV DS,BX | ||
| 266 | ASSUME DS:DOSGROUP | ||
| 267 | INC [INDOS] ; Flag that we're in the DOS | ||
| 268 | XOR AX,AX | ||
| 269 | MOV [USER_ID],AX | ||
| 270 | MOV AX,CurrentPDB ; current process | ||
| 271 | MOV [PROC_ID],AX ; Assume local machine for the moment | ||
| 272 | ; | ||
| 273 | ; Provide one level of reentrancy for INT 24 recallability. | ||
| 274 | ; | ||
| 275 | MOV AX,[user_SP] | ||
| 276 | MOV [NSP],AX | ||
| 277 | MOV AX,[user_SS] | ||
| 278 | MOV [NSS],AX | ||
| 279 | POP AX | ||
| 280 | PUSH AX | ||
| 281 | MOV [user_SP],SP | ||
| 282 | MOV [user_SS],SS | ||
| 283 | ; | ||
| 284 | ; save user stack in his area for later returns (possibly from EXEC) | ||
| 285 | ; | ||
| 286 | MOV DS,[CurrentPDB] | ||
| 287 | ASSUME DS:NOTHING | ||
| 288 | MOV WORD PTR DS:[PDB_User_stack],SP | ||
| 289 | MOV WORD PTR DS:[PDB_User_stack+2],SS | ||
| 290 | |||
| 291 | MOV fSharing,0 ; allow redirection | ||
| 292 | |||
| 293 | MOV BX,CS ; no holes here. | ||
| 294 | MOV SS,BX | ||
| 295 | ASSUME SS:DOSGROUP | ||
| 296 | |||
| 297 | entry REDISP | ||
| 298 | MOV SP,OFFSET DOSGROUP:AUXSTACK ; Enough stack for interrupts | ||
| 299 | STI ; stack is in our space now... | ||
| 300 | IF DBCS ;AN000; | ||
| 301 | MOV BH, BYTE PTR DS:[PDB_InterCon] ;AN000;; get interim mode 2/13/KK | ||
| 302 | MOV SS:[InterCon], BH ;AN000;; 2/13/KK | ||
| 303 | ENDIF ;AN000; | ||
| 304 | MOV BX,CS | ||
| 305 | MOV DS,BX | ||
| 306 | DOSAssume CS,<DS>,"MSCODE/ReDisp" | ||
| 307 | ;; DOS 3.4 INIT | ||
| 308 | ; MOV BL,[CPSWSAVE] ;AN000;;FT. DOS 3.4 | ||
| 309 | ; MOV [CPSWFLAG],BL ;AN000;;FT. DOS 3.4 in case ABORT | ||
| 310 | MOV [DISK_FULL],0 ;AN000;;MS. no disk full | ||
| 311 | MOV [EXTOPEN_ON],0 ;AN000;;EO. clear extended open flag | ||
| 312 | MOV [DOS34_FLAG],0 ;AN000;;MS. clear common flag | ||
| 313 | MOV [ACT_PAGE],-1 ;BN000;BL;AN000;;LB. invalidate active page | ||
| 314 | ;; DOS 4.00 INIT | ||
| 315 | XOR BH,BH | ||
| 316 | MOV [CONSWAP],BH ; random clean up of possibly mis-set flags | ||
| 317 | MOV [IDLEINT],1 ; presume that we can issue INT 28 | ||
| 318 | MOV BYTE PTR [NoSetDir],BH ; set directories on search | ||
| 319 | MOV BYTE PTR [FAILERR],BH ; FAIL not in progress | ||
| 320 | MOV BL,AH | ||
| 321 | SHL BX,1 ; 2 bytes per call in table | ||
| 322 | CLD | ||
| 323 | ; | ||
| 324 | ; Since the DOS maintains mucho state information across system calls, we | ||
| 325 | ; must be very careful about which stack we use. | ||
| 326 | ; | ||
| 327 | ; First, all abort operations must be on the disk stack. THis is due to the | ||
| 328 | ; fact that we may be hitting the disk (close operations, flushing) and may | ||
| 329 | ; need to report an INT 24. | ||
| 330 | ; | ||
| 331 | OR AH,AH | ||
| 332 | JZ DSKROUT ; ABORT | ||
| 333 | ; | ||
| 334 | ; Second, PRINT and PSPRINT and the server issue GetExtendedError calls at | ||
| 335 | ; INT 28 and INT 24 time. This call MUST, therefore, use the AUXSTACK. | ||
| 336 | ; | ||
| 337 | CMP AH,GetExtendedError | ||
| 338 | JZ DISPCALL | ||
| 339 | ; | ||
| 340 | ; Old 1-12 system calls may be either on the IOSTACK (normal operation) or | ||
| 341 | ; on the AUXSTACK (at INT 24 time). | ||
| 342 | ; | ||
| 343 | CMP AH,12 | ||
| 344 | JA DSKROUT | ||
| 345 | CMP [ERRORMODE],0 ; Are we in an INT 24? | ||
| 346 | JNZ DISPCALL ; Stay on AUXSTACK if INT 24. | ||
| 347 | MOV SP,OFFSET DOSGROUP:IOSTACK | ||
| 348 | JMP SHORT DISPCALL | ||
| 349 | ; | ||
| 350 | ; We are on a system call that is classified as "the rest". We place | ||
| 351 | ; ourselves onto the DSKSTACK and away we go. We know at this point: | ||
| 352 | ; | ||
| 353 | ; o An INT 24 cannot be in progress. Therefore we reset errormode and | ||
| 354 | ; wperr | ||
| 355 | ; o That there can be no critical sections in effect. We signal the | ||
| 356 | ; server to remove all the resources. | ||
| 357 | ; | ||
| 358 | DSKROUT: | ||
| 359 | MOV [USER_IN_AX],AX ; Remember what user is doing | ||
| 360 | MOV [EXTERR_LOCUS],errLOC_Unk ; Default | ||
| 361 | MOV [ERRORMODE],0 ; Cannot make non 1-12 calls in | ||
| 362 | MOV [WPERR],-1 ; error mode, so good place to make | ||
| 363 | ; | ||
| 364 | ; Release all resource information | ||
| 365 | ; | ||
| 366 | PUSH AX | ||
| 367 | MOV AH,82h | ||
| 368 | INT int_IBM | ||
| 369 | POP AX | ||
| 370 | |||
| 371 | ; | ||
| 372 | ; Since we are going to be running on the DSKStack and since INT 28 people | ||
| 373 | ; will use the DSKStack, we must turn OFF the generation of INT 28's. | ||
| 374 | ; | ||
| 375 | MOV IdleInt,0 | ||
| 376 | MOV SP,OFFSET DOSGROUP:DSKSTACK | ||
| 377 | TEST [CNTCFLAG],-1 | ||
| 378 | JZ DISPCALL ; Extra ^C checking is disabled | ||
| 379 | PUSH AX | ||
| 380 | invoke DSKSTATCHK | ||
| 381 | POP AX | ||
| 382 | DISPCALL: | ||
| 383 | MOV BX,CS:Dispatch[BX] | ||
| 384 | XCHG BX,SaveBX | ||
| 385 | MOV DS,SaveDS | ||
| 386 | |||
| 387 | IF BUFFERFLAG | ||
| 388 | mov cs:[SETVECTFLAG], 0 | ||
| 389 | cmp ah, 25h | ||
| 390 | jne saveuser | ||
| 391 | cmp ah, 35h | ||
| 392 | jne saveuser | ||
| 393 | mov cs:[SETVECTFLAG], 1 | ||
| 394 | saveuser: | ||
| 395 | invoke SAVE_USER_MAP ;AN000;LB. save EMS map | ||
| 396 | ENDIF | ||
| 397 | |||
| 398 | ASSUME DS:NOTHING | ||
| 399 | CALL SaveBX | ||
| 400 | |||
| 401 | IF BUFFERFLAG | ||
| 402 | invoke RESTORE_USER_MAP ;AN000;LB. retsore EMS map | ||
| 403 | ENDIF | ||
| 404 | |||
| 405 | entry LEAVEDOS | ||
| 406 | ASSUME SS:NOTHING ; User routines may misbehave | ||
| 407 | CLI | ||
| 408 | DEC [INDOS] | ||
| 409 | MOV SS,[user_SS] | ||
| 410 | MOV SP,[user_SP] | ||
| 411 | MOV BP,SP | ||
| 412 | MOV BYTE PTR [BP.user_AX],AL | ||
| 413 | MOV AX,[NSP] | ||
| 414 | MOV [user_SP],AX | ||
| 415 | MOV AX,[NSS] | ||
| 416 | MOV [user_SS],AX | ||
| 417 | CALL restore_world | ||
| 418 | IRET | ||
| 419 | EndProc SYSTEM_CALL | ||
| 420 | |||
| 421 | ; | ||
| 422 | ; restore_world restores all registers ('cept SS:SP, CS:IP, flags) from | ||
| 423 | ; the stack prior to giving the user control | ||
| 424 | ; | ||
| 425 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 426 | procedure restore_world,NEAR | ||
| 427 | POP restore_tmp ; POP restore_tmp | ||
| 428 | POP AX ; PUSH ES | ||
| 429 | POP BX ; PUSH DS | ||
| 430 | POP CX ; PUSH BP | ||
| 431 | POP DX ; PUSH DI | ||
| 432 | POP SI ; PUSH SI | ||
| 433 | POP DI ; PUSH DX | ||
| 434 | POP BP ; PUSH CX | ||
| 435 | POP DS ; PUSH BX | ||
| 436 | POP ES ; PUSH AX | ||
| 437 | JMP restore_tmp ; PUSH restore_tmp | ||
| 438 | EndProc restore_world | ||
| 439 | |||
| 440 | ; | ||
| 441 | ; save_world saves complete registers on the stack | ||
| 442 | ; | ||
| 443 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 444 | procedure save_world,NEAR | ||
| 445 | POP restore_tmp | ||
| 446 | PUSH ES | ||
| 447 | PUSH DS | ||
| 448 | PUSH BP | ||
| 449 | PUSH DI | ||
| 450 | PUSH SI | ||
| 451 | PUSH DX | ||
| 452 | PUSH CX | ||
| 453 | PUSH BX | ||
| 454 | PUSH AX | ||
| 455 | JMP restore_tmp ; PUSH restore_tmp | ||
| 456 | EndProc save_world | ||
| 457 | |||
| 458 | IF BUFFERFLAG | ||
| 459 | |||
| 460 | Break <SAVE_USER_MAP - save map > ;AN000; | ||
| 461 | ; Inputs: ;AN000; | ||
| 462 | ; none ;AN000; | ||
| 463 | ; Function: ;AN000; | ||
| 464 | ; save map ;AN000; | ||
| 465 | ; Outputs: ;AN000; | ||
| 466 | ; none ;AN000; | ||
| 467 | ; No other registers altered ;AN000; | ||
| 468 | ;AN000; | ||
| 469 | Procedure SAVE_USER_MAP,NEAR ;AN000; | ||
| 470 | ASSUME DS:NOTHING,ES:NOTHING ;AN000; | ||
| 471 | ;AN000; | ||
| 472 | CMP cs:[BUF_EMS_MODE],-1 ;LB. EMS support ;AN000; | ||
| 473 | JZ No_user_save ;LB. no ;AN000; | ||
| 474 | CMP cs:[SETVECTFLAG], 1 | ||
| 475 | jz No_user_save | ||
| 476 | ; MOV [ACT_PAGE],-1 ;LB. invalidate active page ;AN000; | ||
| 477 | ; MOV WORD PTR [LASTBUFFER],-1 ;LB. and last buffer pointer ;AN000; | ||
| 478 | PUSH AX ;LB. save regs ;AN000; | ||
| 479 | PUSH DS ;LB. save regs ;AN000; | ||
| 480 | PUSH ES ;LB. ;AN000; | ||
| 481 | PUSH SI ;LB. ;AN000; | ||
| 482 | PUSH DI ;LB. ;AN000; | ||
| 483 | MOV SI,OFFSET DOSGROUP:BUF_EMS_SEG_CNT ;LB. ;AN000; | ||
| 484 | MOV DI,OFFSET DOSGROUP:BUF_EMS_MAP_USER ;LB. ;AN000; | ||
| 485 | |||
| 486 | PUSH CS | ||
| 487 | POP ES | ||
| 488 | PUSH CS ;LB. ds:si -> ems seg cnt ;AN000; | ||
| 489 | POP DS ;LB. ;AN000; | ||
| 490 | |||
| 491 | MOV AX,4F00H ;LB. save map ;AN000; | ||
| 492 | EnterCrit critDisk ;LB. enter critical section ;AN000; | ||
| 493 | INT 67H ;LB. ;AN000; | ||
| 494 | LeaveCrit critDisk ;LB. leave critical section ;AN000; | ||
| 495 | POP DI ;LB. ;AN000; | ||
| 496 | POP SI ;LB. restore regs ;AN000; | ||
| 497 | POP ES ;LB. ;AN000; | ||
| 498 | POP DS ;LB. ;AN000; | ||
| 499 | POP AX ;LB. restore ;AN000; | ||
| 500 | No_user_save: ;AN000; | ||
| 501 | return ;AN000; | ||
| 502 | EndProc SAVE_USER_MAP ;AN000; | ||
| 503 | ;AN000; | ||
| 504 | |||
| 505 | Break <RESTORE_USER_MAP- retore map > ;AN000; | ||
| 506 | ; Inputs: ;AN000; | ||
| 507 | ; none ;AN000; | ||
| 508 | ; Function: ;AN000; | ||
| 509 | ; restore_map ;AN000; | ||
| 510 | ; Outputs: ;AN000; | ||
| 511 | ; none ;AN000; | ||
| 512 | ; No other registers altered ;AN000; | ||
| 513 | ;AN000; | ||
| 514 | Procedure RESTORE_USER_MAP,NEAR ;AN000; | ||
| 515 | ASSUME DS:NOTHING,ES:NOTHING ;AN000; | ||
| 516 | |||
| 517 | CMP cs:[BUF_EMS_MODE],-1 ;LB. EMS support ;AN000; | ||
| 518 | JZ No_user_restore ;LB. no ;AN000; | ||
| 519 | CMP cs:[SETVECTFLAG], 1 | ||
| 520 | jz No_user_restore | ||
| 521 | PUSH AX ;LB. save regs ;AN000; | ||
| 522 | PUSH DS ;LB. save regs ;AN000; | ||
| 523 | PUSH SI ;LB. ;AN000; | ||
| 524 | MOV SI,OFFSET DOSGROUP:BUF_EMS_MAP_USER ;LB. ;AN000; | ||
| 525 | |||
| 526 | PUSH CS | ||
| 527 | POP DS | ||
| 528 | |||
| 529 | MOV AX,4F01H ;LB. restore map ;AN000; | ||
| 530 | EnterCrit critDisk ;LB. enter critical section ;AN000; | ||
| 531 | INT 67H ;LB. ;AN000; | ||
| 532 | LeaveCrit critDisk ;LB. leave critical section ;AN000; | ||
| 533 | POP SI ;LB. restore regs ;AN000; | ||
| 534 | POP DS ;LB. ;AN000; | ||
| 535 | POP AX ;LB. ;AN000; | ||
| 536 | No_user_restore: ;AN000; | ||
| 537 | return ;AN000; | ||
| 538 | EndProc RESTORE_USER_MAP | ||
| 539 | |||
| 540 | ENDIF | ||
| 541 | |||
| 542 | ; | ||
| 543 | ; get_user_stack returns the user's stack (and hence registers) in DS:SI | ||
| 544 | ; | ||
| 545 | procedure get_user_stack,NEAR | ||
| 546 | LDS SI,DWORD PTR [user_SP] | ||
| 547 | return | ||
| 548 | EndProc get_user_stack | ||
| 549 | |||
| 550 | IF NOT IBM | ||
| 551 | BREAK <Set_OEM_Handler -- Set OEM sys call address and handle OEM Calls | ||
| 552 | |||
| 553 | $SET_OEM_HANDLER: | ||
| 554 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 555 | |||
| 556 | ; Inputs: | ||
| 557 | ; User registers, User Stack, INTS disabled | ||
| 558 | ; If CALL F8, DS:DX is new handler address | ||
| 559 | ; Function: | ||
| 560 | ; Process OEM INT 21 extensions | ||
| 561 | ; Outputs: | ||
| 562 | ; Jumps to OEM_HANDLER if appropriate | ||
| 563 | |||
| 564 | JNE DO_OEM_FUNC ; If above F8 try to jump to handler | ||
| 565 | MOV WORD PTR [OEM_HANDLER],DX ; Set Handler | ||
| 566 | MOV WORD PTR [OEM_HANDLER+2],DS | ||
| 567 | IRET ; Quick return, Have altered no registers | ||
| 568 | |||
| 569 | DO_OEM_FUNC: | ||
| 570 | CMP WORD PTR [OEM_HANDLER],-1 | ||
| 571 | JNZ OEM_JMP | ||
| 572 | JMP BADCALL ; Handler not initialized | ||
| 573 | |||
| 574 | OEM_JMP: | ||
| 575 | JMP [OEM_HANDLER] | ||
| 576 | ENDIF | ||
| 577 | |||
| 578 | |||
| 579 | CODE ENDS | ||