diff options
Diffstat (limited to 'v2.0/source/PROC.ASM')
| -rw-r--r-- | v2.0/source/PROC.ASM | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/v2.0/source/PROC.ASM b/v2.0/source/PROC.ASM new file mode 100644 index 0000000..abc6f9c --- /dev/null +++ b/v2.0/source/PROC.ASM | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | ; | ||
| 2 | ; process control system calls for MSDOS | ||
| 3 | ; | ||
| 4 | |||
| 5 | INCLUDE DOSSEG.ASM | ||
| 6 | |||
| 7 | CODE SEGMENT BYTE PUBLIC 'CODE' | ||
| 8 | ASSUME SS:DOSGROUP,CS:DOSGROUP | ||
| 9 | |||
| 10 | .xlist | ||
| 11 | .xcref | ||
| 12 | INCLUDE DOSSYM.ASM | ||
| 13 | INCLUDE DEVSYM.ASM | ||
| 14 | .cref | ||
| 15 | .list | ||
| 16 | |||
| 17 | i_need CurrentPDB,WORD | ||
| 18 | i_need CreatePDB,BYTE | ||
| 19 | i_need NUMIO,BYTE | ||
| 20 | i_need Exit_type,BYTE | ||
| 21 | i_need INDOS,BYTE | ||
| 22 | i_need DMAADD,DWORD | ||
| 23 | i_need DidCTRLC,BYTE | ||
| 24 | |||
| 25 | SUBTTL $WAIT - return previous process error code | ||
| 26 | PAGE | ||
| 27 | ; | ||
| 28 | ; process control data | ||
| 29 | ; | ||
| 30 | i_need exit_code,WORD ; code of exit | ||
| 31 | |||
| 32 | ; | ||
| 33 | ; Assembler usage: | ||
| 34 | ; MOV AH, Wait | ||
| 35 | ; INT int_command | ||
| 36 | ; AX has the exit code | ||
| 37 | procedure $WAIT,NEAR | ||
| 38 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 39 | MOV AX,[exit_code] | ||
| 40 | XOR DX,DX | ||
| 41 | MOV [exit_code],DX | ||
| 42 | transfer SYS_RET_OK | ||
| 43 | $WAIT ENDP | ||
| 44 | |||
| 45 | IF IBM | ||
| 46 | procedure $EXEC,NEAR | ||
| 47 | error error_invalid_function | ||
| 48 | $EXEC ENDP | ||
| 49 | ENDIF | ||
| 50 | IF NOT IBM | ||
| 51 | INCLUDE EXEC.ASM | ||
| 52 | ENDIF | ||
| 53 | |||
| 54 | SUBTTL Terminate and stay resident handler | ||
| 55 | PAGE | ||
| 56 | ; | ||
| 57 | ; Input: DX is an offset from CurrentPDB at which to | ||
| 58 | ; truncate the current block. | ||
| 59 | ; | ||
| 60 | ; output: The current block is truncated (expanded) to be [DX+15]/16 | ||
| 61 | ; paragraphs long. An exit is simulated via resetting CurrentPDB | ||
| 62 | ; and restoring the vectors. | ||
| 63 | ; | ||
| 64 | procedure $Keep_process,NEAR | ||
| 65 | ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP | ||
| 66 | |||
| 67 | PUSH AX ; keep exit code around | ||
| 68 | MOV BYTE PTR [Exit_type],Exit_keep_process | ||
| 69 | MOV ES,[CurrentPDB] | ||
| 70 | CMP DX,6h ; keep enough space around for system | ||
| 71 | JAE Keep_shrink ; info | ||
| 72 | MOV DX,6h | ||
| 73 | keep_shrink: | ||
| 74 | MOV BX,DX | ||
| 75 | PUSH BX | ||
| 76 | PUSH ES | ||
| 77 | invoke $SETBLOCK ; ignore return codes. | ||
| 78 | POP DS | ||
| 79 | POP BX | ||
| 80 | JC keep_done ; failed on modification | ||
| 81 | MOV AX,DS | ||
| 82 | ADD AX,BX | ||
| 83 | MOV DS:[PDB_block_len],AX | ||
| 84 | |||
| 85 | keep_done: | ||
| 86 | POP AX | ||
| 87 | JMP SHORT exit_inner ; and let abort take care of the rest | ||
| 88 | |||
| 89 | $Keep_process ENDP | ||
| 90 | |||
| 91 | procedure Stay_resident,NEAR | ||
| 92 | ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 93 | MOV AX,(Keep_process SHL 8) + 0 ; Lower part is return code | ||
| 94 | ADD DX,15 | ||
| 95 | MOV CL,4 | ||
| 96 | SHR DX,CL | ||
| 97 | |||
| 98 | transfer COMMAND | ||
| 99 | Stay_resident ENDP | ||
| 100 | |||
| 101 | SUBTTL $EXIT - return to parent process | ||
| 102 | PAGE | ||
| 103 | ; | ||
| 104 | ; Assembler usage: | ||
| 105 | ; MOV AL, code | ||
| 106 | ; MOV AH, Exit | ||
| 107 | ; INT int_command | ||
| 108 | ; Error return: | ||
| 109 | ; None. | ||
| 110 | ; | ||
| 111 | procedure $EXIT,NEAR | ||
| 112 | ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP | ||
| 113 | XOR AH,AH | ||
| 114 | XCHG AH,BYTE PTR [DidCTRLC] | ||
| 115 | OR AH,AH | ||
| 116 | MOV BYTE PTR [Exit_type],exit_terminate | ||
| 117 | JZ exit_inner | ||
| 118 | MOV BYTE PTR [Exit_type],exit_ctrl_c | ||
| 119 | |||
| 120 | Exit_inner: | ||
| 121 | invoke get_user_stack | ||
| 122 | PUSH [CurrentPDB] | ||
| 123 | POP [SI.user_CS] | ||
| 124 | transfer abort_inner | ||
| 125 | $EXIT ENDP | ||
| 126 | |||
| 127 | do_ext | ||
| 128 | |||
| 129 | CODE ENDS | ||
| 130 | END | ||