summaryrefslogtreecommitdiff
path: root/v4.0/src/SELECT/SCN_PARM.ASM
diff options
context:
space:
mode:
authorGravatar Mark Zbikowski2024-04-25 21:24:10 +0100
committerGravatar Microsoft Open Source2024-04-25 22:32:27 +0000
commit2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch)
tree80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/SELECT/SCN_PARM.ASM
parentMerge pull request #430 from jpbaltazar/typoptbr (diff)
downloadms-dos-main.tar.gz
ms-dos-main.tar.xz
ms-dos-main.zip
MZ is back!HEADmain
Diffstat (limited to 'v4.0/src/SELECT/SCN_PARM.ASM')
-rw-r--r--v4.0/src/SELECT/SCN_PARM.ASM299
1 files changed, 299 insertions, 0 deletions
diff --git a/v4.0/src/SELECT/SCN_PARM.ASM b/v4.0/src/SELECT/SCN_PARM.ASM
new file mode 100644
index 0000000..5b6a9fd
--- /dev/null
+++ b/v4.0/src/SELECT/SCN_PARM.ASM
@@ -0,0 +1,299 @@
1;********************************************************************************
2; File: SCN_PARM.ASM
3;
4; Subroutine for scanning the SELECT command line, and if the appropriate
5; parameter is specified, additional information is read from the disk.
6;
7;********************************************************************************
8.ALPHA ;AN000;
9.XLIST ;AN000;
10INCLUDE MACROS.INC ;AN000;
11INCLUDE STRUC.INC ;AN000;
12INCLUDE EXT.INC ;AN000;
13.LIST ;AN000;
14
15
16PUBLIC SCAN_PARAMETERS_ROUTINE ;AN000;
17EXTRN SYSPARSE:FAR ;AN000;
18EXTRN POS_ZERO:FAR ;AN000;
19EXTRN HOOK_INT_24:FAR ;AN000;
20EXTRN RESTORE_INT_24:FAR ;AN000;
21EXTRN CLOSE_FILE_ROUTINE:FAR ;AN000;
22
23
24DATA SEGMENT BYTE PUBLIC 'DATA';AN000;
25
26PARMS LABEL BYTE ;AN000;
27 PAR_EXTEN DW PARMSX ;AN000; Offset of the PARMS EXTENSION BLOCK
28 PAR_NUM DB 0 ;AN000; The number of further definitions
29
30; The PARMS EXTENSION BLOCK
31PARMSX LABEL BYTE ;AN000;
32 PAX_MINP DB 1 ;AN000;
33 PAX_MAXP DB 1 ;AN000;
34 DW OFFSET CONTROL_P1;AN000;
35 PAX_MAX_SW DB 0 ;AN000;
36 PAX_MAX_K1 DB 0 ;AN000;
37
38CONTROL_P1 LABEL BYTE ;AN000;
39 DW 02000H ;AN000;
40 DW 0000H ;AN000;
41 DW RESULT_P1 ;AN000;
42 DW VALUE_LIST_P1 ;AN000;
43 DB 0 ;AN000;
44
45VALUE_LIST_P1 LABEL BYTE ;AN000;
46 DB 3 ;AN000; Number of value definitions
47 DB 0 ;AN000; Number of range definitions
48 DB 0 ;AN000; Number of actual value definitions
49 DB 2 ;AN000; Number of string definitions
50 DB 0 ;AN000; Value to be returned if this string is matched
51 DW OFFSET KEYWORD_MENU;AN000;
52 DB 1 ;AN000; Value to be returned if this string is matched
53 DW OFFSET KEYWORD_FDISK ;AN000;
54
55KEYWORD_MENU DB 'MENU',0 ;AN000;
56KEYWORD_FDISK DB 'FDISK',0 ;AN000;
57
58RESULT_P1 LABEL BYTE ;AN000;
59 DB 0 ;AN000; Type of operand returned
60 DB 0 ;AN000; Matched item tag
61 DW 0 ;AN000; Offset of synonym returned
62 DB 0,0,0,0 ;AN000; Unsure what this is...
63
64
65MODE DW 0 ;AN000;
66option_0 dw 0
67OPTION_1 DW 0 ;AN000;
68OPTION_2 DW 0 ;AN000;
69OPTION_3 DW 0 ;AN033;SEH
70FILE_HANDLE DW 0 ;AN000;
71
72DATA ENDS ;AN000;
73
74CODE_FAR SEGMENT BYTE PUBLIC 'CODE' ;AN000;
75
76 ASSUME CS:CODE_FAR, DS:DATA, ES:DATA ;AN000;
77
78;****************************************************************************
79;
80; SCAN_PARAMETERS_ROUTINE: Scan SELECT command line for parameters.
81;
82; SYNTAX: SCAN_PARAMETERS mode, option, path, filename, buffer, buff_size
83;
84; INPUT:
85; DI = The name of the file which contains the FDISK parameters.
86; (ASCII-N format)
87; SI = A buffer where the data read from the file can be stored.
88; CX = The size of the buffer.
89;
90; OUTPUT:
91; AX = Install mode
92; = 0: Parameter is MENU
93; = 1: Parameter is FDISK
94; = 0FFH: Parameter is invalid
95; BX = 0
96; = 1
97; = 2
98; = 0FFh: Parameter is invalid (not 0, 1, 2)
99; CX = 0,1,2
100; DI = Install path in ASCII-N format
101;
102; OPERATION: The SELECT command line is scanned for parameters. The
103; return codes for the various parameters are provided in variables
104; defined above. If the parameter on the command line is FDISK, then
105; the file specified in FILENAME is opened and additional parameters
106; are read. If the parameters in the file are invalid, or if the file
107; cannot be found, then 0FFh is returned in MODE and OPTION, and the
108; path length is set to zero.
109;
110; Note:
111; Before this macro is executed, there must be as ASSUME ES:DATA
112; statement. If not, the parser will not execute properly and
113; either the computer will hang or erroneous values will be returned.
114;
115;****************************************************************************
116 PATH EQU [BP+12] ;AN000;
117 FILENAME EQU [BP+10] ;AN000;
118 BUFFER EQU [BP+8] ;AN000;
119 BUFF_SIZE EQU [BP+6] ;AN000;
120 ;
121SCAN_PARAMETERS_ROUTINE PROC FAR ;AN000;
122 PUSH BP ;AN000;
123 MOV BP, SP ;AN000;
124 ;
125 MOV OPTION_1, E_SELECT_INV ;AN000;
126 MOV OPTION_2, E_SELECT_INV ;AN000;
127 ;
128 PUSH ES ;AN000; Save the extra register
129 MOV AX, DATA ;AN000; ES contain control block segment
130 MOV ES, AX ;AN000;
131 MOV DI, OFFSET PARMS ;AN000; DI contains offset of control block
132 MOV SI, 0081H ;AN000; SI contains offset of command line
133 MOV DX, 0 ;AN000; DX and CX must be zero
134 MOV CX, 0 ;AN000;
135 MOV AH, 062H ;AN000; Get the PSP segment
136 DOSCALL ;AN000;
137 ;
138 PUSH BX ;AN000; Save for later reference
139NEXT_PARSE: ;AN000;
140 POP AX ;AN000; Get the PSP segment
141 PUSH AX ;AN000; Place on stack again
142 PUSH DS ;AN000; Save the current data segment
143 MOV DS, AX ;AN000; Load DS with the segment of the command line
144 CALL SYSPARSE ;AN000; Parse the command line
145 POP DS ;AN000; Restore the data segment
146 ;
147 .IF < AX EQ 0 > ;AN000; Were there any errors?
148 MOV BX, DX ;AN000; No! Get the address of the result block
149 MOV AL, [BX]+1 ;AN000; Yes! Get the returned value
150 MOV AH, 0 ;AN000; Zero the high byte
151 MOV MODE, AX ;AN000; Store the result
152 JMP NEXT_PARSE ;AN000; Parse the next parameter
153 .ELSEIF < AX NE -1 > ;AN000; If there was an error, indicate so.
154 MOV MODE, E_SELECT_INV ;AN000; Return that the values are invalid
155 MOV OPTION_1, E_SELECT_INV ;AN000;
156 MOV OPTION_2, E_SELECT_INV ;AN000;
157 .ENDIF ;AN000;
158 POP AX ;AN000; Take the PSP segment off the stack
159 MOV AX,MODE ;AN000; Store the result
160 POP ES ;AN000;
161 POP BP ;AN000;
162 RET ;AN000;
163SCAN_PARAMETERS_ROUTINE ENDP ;AN000;
164;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165;
166; SCAN_INFO_FILE_ROUTINE: Scan SELECT.TMP file for parameters.
167;
168; INPUT:
169; The following variables have been passed to this routine from the
170; SCAN_INFO_FILE macro by pushing them on the stack:
171; PATH EQU [BP+12]
172; FILENAME EQU [BP+10]
173; BUFFER EQU [BP+8]
174; BUFF_SIZE EQU [BP+6]
175;
176; OUTPUT:
177; AX = Install mode
178; = 0: Parameter is MENU
179; = 1: Parameter is FDISK
180; = 0FFH: Parameter is invalid
181; BX = 1
182; = 2
183; = 3
184; = 0FFh: Parameter is invalid (not 1, 2, 3)
185; CX = 1
186; = 2
187; = 0FFh: Parameter is invalid (not 1, 2)
188; DX = 1
189; = 2
190; = 0FFh: Parameter is invalid (not 1, 2)
191;
192;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
193 PUBLIC SCAN_INFO_FILE_ROUTINE ;AN000;
194SCAN_INFO_FILE_ROUTINE PROC FAR ;AN000;
195 CALL HOOK_INT_24 ;AN000;
196 ;
197 PUSH BP ;AN000;
198 MOV BP, SP ;AN000;
199 MOV OPTION_0, E_SELECT_INV ;AN000;
200 MOV OPTION_1, E_SELECT_INV ;AN000;
201 MOV OPTION_2, E_SELECT_INV ;AN000;
202 MOV OPTION_3, E_SELECT_INV ;AN033;SEH
203 PUSH ES ;AN000; Save the extra register
204 ;
205 .IF < MODE NE E_SELECT_INV> AND NEAR ;AN000; If no error has occured yet,
206 .IF < MODE EQ 1 > NEAR ;AN000; and if the parameter was FDISK...
207 MOV DI, FILENAME ;AN000; Get the offset of the filename
208 CALL POS_ZERO ;AN000; Make into an ASCII-Z string
209 MOV DX, DI ;AN000; Load filename offset again
210 ADD DX, 2 ;AN000; Adjust pointer past the length word
211 MOV AX, 3D00H ;AN000; Fn call for opening a file for reading
212 DOSCALL ;AN000; Open the file
213 .IF < C > ;AN000; If there was as error, do not continue
214 JMP FILE_ERROR ;AN000; Return INVALID parameters to the caller
215 .ENDIF ;AN000;
216 MOV FILE_HANDLE, AX ;AN000; Save the returned file handle
217 MOV AH, 3FH ;AN000; DOS Fn for reading from a file
218 MOV DX, BUFFER ;AN000; Get the offset of the data buffer
219 MOV CX, BUFF_SIZE ;AN000; Get the number of bytes in the buffer
220 MOV BX, FILE_HANDLE ;AN000; Get the file handle for the opened file
221 DOSCALL ;AN000; Read from the file
222 .IF < C > ;AN000; If there was an error, do not continue
223 JMP FILE_ERROR ;AN000; Return INVALID parameters to the caller
224 .ENDIF ;AN000;
225 MOV SI, BUFFER ;AN000; Get the offset of the data buffer
226 MOV BH, 0 ;AN000; Zero the high byte
227 MOV BL, BYTE PTR [SI] ;AN000; Get the first byte from the file
228 SUB BL, '0' ;AN000; Turn into a binary number
229 MOV OPTION_0, BX ;AN000; Save this as the first option
230 MOV BL, BYTE PTR [SI+3] ;AN000; Get the first byte from the file
231 SUB BL, '0' ;AN000; Turn into a binary number
232 MOV OPTION_1, BX ;AN000; Save this as the first option
233 MOV BL, BYTE PTR [SI+6] ;AN000; Get the second option in the file
234 SUB BL, '0' ;AN000; Make into a binary value
235 MOV OPTION_2, BX ;AN000; Save this second option
236 MOV BL, BYTE PTR [SI+9] ;AN033; SEH Get the third option in the file
237 SUB BL, '0' ;AN033; SEH Make into a binary value
238 MOV OPTION_3, BX ;AN033; SEH Save this third option
239 MOV SI, BUFFER ;AN000; Get the offset of the data buffer
240 ADD SI, 12 ;AC033; SEH Point to the start of the path line
241 MOV DI, PATH ;AN000; Get the offset of the path storage
242 MOV BX, DI ;AN000;
243 ADD DI, 2 ;AN000; Adjust pointer past the length word
244 ; AX contains the number of characters read from the file
245 SUB AX, 12 ;AC033; SEH Number of characters left in the buffer
246 MOV CX, 0 ;AN000; Number of characters in the path string
247 MOV WORD PTR [BX], 0 ;AN000; Zero the string length to begin
248 .WHILE < AX GT 0 > ;AN000; Continue while there are characters left
249 MOV DL, [SI] ;AN000; Get the character from the buffer
250 .IF < DL EQ E_CR > OR ;AN000; See if this is the end of the line
251 .IF < DL EQ E_LF > ;AN000;
252 MOV [BX], CX ;AN000; Store the length of path
253 .LEAVE ;AN000;
254 .ENDIF ;AN000;
255 MOV [DI], DL ;AN000; Store the byte in the path
256 INC DI ;AN000; Increment the path pointer
257 INC SI ;AN000; Increment the source pointer
258 INC CX ;AN000; Increment the count of characters
259 DEC AX ;AN000; Decrement the numbers of characters left
260 .IF < CX A M_INSTALL_PATH > ;AN000; If more then 40 characters then an error
261 JMP FILE_ERROR ;AN000;
262 .ENDIF ;AN000;
263 .ENDWHILE ;AN000;
264 .IF < OPTION_1 AE 1 > AND ;AN000; If option is 1 or 2 then a path is needed
265 .IF < OPTION_1 BE 3 > ;AN000;
266 .IF < <WORD PTR [BX]> EQ 0 > ;AN000; If the path length was 0, return error
267 JMP FILE_ERROR ;AN000;
268 .ENDIF ;AN000;
269 .ELSE ;AN000;
270 .IF < <WORD PTR [BX]> NE 0 > ;AN000; If option is 3 and there is a path, error
271 JMP FILE_ERROR ;AN000;
272 .ENDIF ;AN000;
273 .ENDIF ;AN000;
274 JMP CLOSE_THE_FILE ;AN000;
275FILE_ERROR: ;AN000; Here if there has been an error
276 MOV MODE, E_SELECT_INV ;AN000;
277 MOV OPTION_1, E_SELECT_INV ;AN000;
278 MOV OPTION_2, E_SELECT_INV ;AN000;
279 MOV OPTION_3, E_SELECT_INV ;AN033; SEH
280 MOV BX, PATH ;AN000;
281 MOV WORD PTR [BX], 0 ;AN000;
282CLOSE_THE_FILE: ;AN000; Close the file
283 MOV BX, FILE_HANDLE ;AN000; Get the file handle
284 CLOSE_FILE BX ;AN000; Close the file
285 .ENDIF ;AN000;
286 MOV AX, option_0 ;AN000; Return the parameters
287 MOV BX, OPTION_1 ;AN000;
288 MOV CX, OPTION_2 ;AN000;
289 MOV DX, OPTION_3 ;AN033; SEH
290 ;
291 POP ES ;AN000; Restore the extra segment
292 POP BP ;AN000;
293 CALL RESTORE_INT_24 ;AN000;
294 RET 8 ;AN000;
295SCAN_INFO_FILE_ROUTINE ENDP ;AN000;
296;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297CODE_FAR ENDS ;AN000;
298 ;
299END ;AN000;