diff options
Diffstat (limited to 'v4.0/src/DOS/PROC.ASM')
| -rw-r--r-- | v4.0/src/DOS/PROC.ASM | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/v4.0/src/DOS/PROC.ASM b/v4.0/src/DOS/PROC.ASM new file mode 100644 index 0000000..1e54034 --- /dev/null +++ b/v4.0/src/DOS/PROC.ASM | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | ; SCCSID = @(#)proc.asm 1.1 85/04/10 | ||
| 2 | TITLE IBMPROC - process maintenance | ||
| 3 | NAME IBMPROC | ||
| 4 | |||
| 5 | ; | ||
| 6 | ; Process related system calls and low level routines for DOS 2.X. | ||
| 7 | ; I/O specs are defined in DISPATCH. | ||
| 8 | ; | ||
| 9 | ; $WAIT | ||
| 10 | ; $EXEC | ||
| 11 | ; $Keep_process | ||
| 12 | ; Stay_resident | ||
| 13 | ; $EXIT | ||
| 14 | ; $ABORT | ||
| 15 | ; abort_inner | ||
| 16 | ; | ||
| 17 | ; Modification history: | ||
| 18 | ; | ||
| 19 | ; Created: ARR 30 March 1983 | ||
| 20 | ; | ||
| 21 | |||
| 22 | .xlist | ||
| 23 | ; | ||
| 24 | ; get the appropriate segment definitions | ||
| 25 | ; | ||
| 26 | include dosseg.asm | ||
| 27 | |||
| 28 | CODE SEGMENT BYTE PUBLIC 'CODE' | ||
| 29 | ASSUME SS:DOSGROUP,CS:DOSGROUP | ||
| 30 | |||
| 31 | .xcref | ||
| 32 | INCLUDE DOSSYM.INC | ||
| 33 | INCLUDE DEVSYM.INC | ||
| 34 | .cref | ||
| 35 | .list | ||
| 36 | |||
| 37 | SAVEXIT EQU 10 | ||
| 38 | |||
| 39 | i_need CurrentPDB,WORD | ||
| 40 | i_need CreatePDB,BYTE | ||
| 41 | i_need Exit_type,BYTE | ||
| 42 | i_need INDOS,BYTE | ||
| 43 | i_need DMAADD,DWORD | ||
| 44 | i_need DidCTRLC,BYTE | ||
| 45 | i_need exit_type,BYTE | ||
| 46 | i_need exit_code,WORD | ||
| 47 | i_need OpenBuf,128 | ||
| 48 | I_need EXTERR_LOCUS,BYTE ; Extended Error Locus | ||
| 49 | |||
| 50 | SUBTTL $WAIT - return previous process error code | ||
| 51 | PAGE | ||
| 52 | ; | ||
| 53 | ; process control data | ||
| 54 | ; | ||
| 55 | i_need exit_code,WORD ; code of exit | ||
| 56 | |||
| 57 | ; | ||
| 58 | ; Assembler usage: | ||
| 59 | ; MOV AH, WaitProcess | ||
| 60 | ; INT int_command | ||
| 61 | ; AX has the exit code | ||
| 62 | procedure $WAIT,NEAR | ||
| 63 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 64 | XOR AX,AX | ||
| 65 | XCHG AX,exit_code | ||
| 66 | transfer SYS_RET_OK | ||
| 67 | EndProc $WAIT | ||
| 68 | |||
| 69 | include exec.asm | ||
| 70 | |||
| 71 | SUBTTL Terminate and stay resident handler | ||
| 72 | PAGE | ||
| 73 | ; | ||
| 74 | ; Input: DX is an offset from CurrentPDB at which to | ||
| 75 | ; truncate the current block. | ||
| 76 | ; | ||
| 77 | ; output: The current block is truncated (expanded) to be [DX+15]/16 | ||
| 78 | ; paragraphs long. An exit is simulated via resetting CurrentPDB | ||
| 79 | ; and restoring the vectors. | ||
| 80 | ; | ||
| 81 | procedure $Keep_process,NEAR | ||
| 82 | ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP | ||
| 83 | |||
| 84 | PUSH AX ; keep exit code around | ||
| 85 | MOV BYTE PTR [Exit_type],Exit_keep_process | ||
| 86 | MOV ES,[CurrentPDB] | ||
| 87 | CMP DX,6h ; keep enough space around for system | ||
| 88 | JAE Keep_shrink ; info | ||
| 89 | MOV DX,6h | ||
| 90 | keep_shrink: | ||
| 91 | MOV BX,DX | ||
| 92 | PUSH BX | ||
| 93 | PUSH ES | ||
| 94 | invoke $SETBLOCK ; ignore return codes. | ||
| 95 | POP DS | ||
| 96 | POP BX | ||
| 97 | JC keep_done ; failed on modification | ||
| 98 | MOV AX,DS | ||
| 99 | ADD AX,BX | ||
| 100 | MOV DS:[PDB_block_len],AX | ||
| 101 | |||
| 102 | keep_done: | ||
| 103 | POP AX | ||
| 104 | JMP SHORT exit_inner ; and let abort take care of the rest | ||
| 105 | |||
| 106 | EndProc $Keep_process | ||
| 107 | |||
| 108 | procedure Stay_resident,NEAR | ||
| 109 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 110 | MOV AX,(Keep_process SHL 8) + 0 ; Lower part is return code | ||
| 111 | ADD DX,15 | ||
| 112 | RCR DX,1 | ||
| 113 | MOV CL,3 | ||
| 114 | SHR DX,CL | ||
| 115 | |||
| 116 | transfer COMMAND | ||
| 117 | EndProc Stay_resident | ||
| 118 | |||
| 119 | SUBTTL $EXIT - return to parent process | ||
| 120 | PAGE | ||
| 121 | ; | ||
| 122 | ; Assembler usage: | ||
| 123 | ; MOV AL, code | ||
| 124 | ; MOV AH, Exit | ||
| 125 | ; INT int_command | ||
| 126 | ; Error return: | ||
| 127 | ; None. | ||
| 128 | ; | ||
| 129 | procedure $EXIT,NEAR | ||
| 130 | ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP | ||
| 131 | XOR AH,AH | ||
| 132 | XCHG AH,BYTE PTR [DidCTRLC] | ||
| 133 | OR AH,AH | ||
| 134 | MOV BYTE PTR [Exit_type],exit_terminate | ||
| 135 | JZ exit_inner | ||
| 136 | MOV BYTE PTR [Exit_type],exit_ctrl_c | ||
| 137 | |||
| 138 | entry Exit_inner | ||
| 139 | |||
| 140 | invoke get_user_stack | ||
| 141 | PUSH [CurrentPDB] | ||
| 142 | POP [SI.user_CS] | ||
| 143 | JMP SHORT abort_inner | ||
| 144 | EndProc $EXIT | ||
| 145 | |||
| 146 | BREAK <$ABORT -- Terminate a process> | ||
| 147 | |||
| 148 | ; Inputs: | ||
| 149 | ; user_CS:00 must point to valid program header block | ||
| 150 | ; Function: | ||
| 151 | ; Restore terminate and Cntrl-C addresses, flush buffers and transfer to | ||
| 152 | ; the terminate address | ||
| 153 | ; Returns: | ||
| 154 | ; TO THE TERMINATE ADDRESS | ||
| 155 | |||
| 156 | procedure $ABORT,NEAR | ||
| 157 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 158 | |||
| 159 | XOR AL,AL | ||
| 160 | MOV [exit_type],exit_abort | ||
| 161 | |||
| 162 | ; | ||
| 163 | ; abort_inner must have AL set as the exit code! The exit type is retrieved | ||
| 164 | ; from exit_type. Also, the PDB at user_CS needs to be correct as the one | ||
| 165 | ; that is terminating. | ||
| 166 | ; | ||
| 167 | entry abort_inner | ||
| 168 | |||
| 169 | MOV AH,[exit_type] | ||
| 170 | MOV [exit_code],AX | ||
| 171 | invoke Get_user_stack | ||
| 172 | MOV DS,[SI.user_CS] ; set up old interrupts | ||
| 173 | XOR AX,AX | ||
| 174 | MOV ES,AX | ||
| 175 | MOV SI,SAVEXIT | ||
| 176 | MOV DI,addr_int_terminate | ||
| 177 | MOVSW | ||
| 178 | MOVSW | ||
| 179 | MOVSW | ||
| 180 | MOVSW | ||
| 181 | MOVSW | ||
| 182 | MOVSW | ||
| 183 | transfer reset_environment | ||
| 184 | EndProc $ABORT | ||
| 185 | |||
| 186 | CODE ENDS | ||
| 187 | END | ||