summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/EDLIN/EDLPARSE.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/CMD/EDLIN/EDLPARSE.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/CMD/EDLIN/EDLPARSE.ASM')
-rw-r--r--v4.0/src/CMD/EDLIN/EDLPARSE.ASM281
1 files changed, 281 insertions, 0 deletions
diff --git a/v4.0/src/CMD/EDLIN/EDLPARSE.ASM b/v4.0/src/CMD/EDLIN/EDLPARSE.ASM
new file mode 100644
index 0000000..32f6f4c
--- /dev/null
+++ b/v4.0/src/CMD/EDLIN/EDLPARSE.ASM
@@ -0,0 +1,281 @@
1
2 page 60,132;
3 title EDLPARSE for EDLIN
4
5
6;******************* START OF SPECIFICATIONS *****************************
7;
8; MODULE NAME: EDLPARSE.SAL
9;
10; DESCRIPTIVE NAME: PARSES THE EXTERNAL COMMAND LINE FOR EDLIN
11;
12; FUNCTION: THIS ROUTINE PROVIDES PARSING CAPABILITIES FOR THE
13; EXTERNAL COMMAND LINE OF EDLIN. IT PARSES FOR THE PRESENCE
14; OF A REQUIRED FILESPEC AND AN OPTIONAL SWITCH (/B).
15;
16; ENTRY POINT: PARSER_COMMAND
17;
18; INPUT: DOS COMMAND LINE
19;
20; EXIT NORMAL: AX = 0FFH - VALID SWITCH AND FILESPEC SPECIFIED
21;
22; EXIT ERROR: AX NOT= 0FFH - INVALID SWITCH OR NO FILESPEC SPECIFIED
23;
24; INTERNAL REFERENCES
25;
26; ROUTINE: PARSER_COMMAND - THIS ROUTINE PARSES FOR THE PRESENCE
27; OF THE /B SWITCH AND A FILESPEC. THE
28; FILEPSEC IS REQUIRED, WHILE THE SWITCH
29; IS OPTIONAL.
30;
31; EXTERNAL REFERENCES:
32;
33; ROUTINE: PARSE.ASM - THIS IS THE PARSER CODE.
34;
35; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
36; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
37;
38; REVISION HISTORY:
39;
40; AN000 VERSION 4.00 - IMPLEMENTS THE SYSTEM PARSER (SYSPARSE)
41;
42; COPYRIGHT: "THE IBM PERSONAL COMPUTER EDLIN UTILITY"
43; "VERSION 4.00 (C) COPYRIGHT 1988"
44; "LICENSED MATERIAL - PROPERTY OF Microsoft"
45;
46;
47;******************** END OF SPECIFICATIONS ******************************
48
49
50;======================= equates for edlparse ============================
51
52parse_ok equ 0 ;an000;good parse return
53parse_command equ 081h ;an000;offset of command line
54nul equ 0 ;an000;nul
55fs_flag equ 05h ;an000;filespec found
56sw_flag equ 03h ;an000;switch found
57true equ 0ffffh ;an000;true
58false equ 00h ;an000;false
59too_many equ 01h ;an000;too many parms
60
61;======================= end equates =====================================
62
63
64CODE SEGMENT PUBLIC BYTE
65CODE ENDS
66
67CONST SEGMENT PUBLIC BYTE
68CONST ENDS
69
70cstack segment stack
71cstack ends
72
73DATA SEGMENT PUBLIC BYTE
74
75 extrn path_name:byte
76 extrn org_ds:word ;an000; dms;
77
78 public parse_switch_b ;an000;parse switch result
79 public filespec ;an000;actual filespec
80
81;======================= input parameters control blocks =================
82; these control blocks are used by sysparse and must be pointed to by
83; es:di on invocation.
84
85 public parms ;an000;share parms
86parms label byte ;an000;parms control block
87 dw dg:parmsx ;an000;point to parms structure
88 db 00h ;an000;no additional delims.
89
90parmsx label byte ;an000;parameter types
91 db 1,1 ;an000;must have filespec
92 dw dg:fs_pos ;an000;filespec control block
93 db 1 ;an000;max. number of switches
94 dw dg:sw_b ;an000;\b switch control block
95 db 00h ;an000;no keywords
96
97;======================= filespec positional tables ======================
98
99fs_pos label byte ;an000;filespec positional
100 dw 0200h ;an000;filespec/not optional
101 dw 0001h ;an000;cap
102 dw dg:filespec_res ;an000;filespec result table
103 dw dg:noval ;an000;value list/none
104 db 0 ;an000;no keyword/switch syns.
105
106filespec_res label byte ;an000;filespec result table
107parse_fs_res db ? ;an000;must be filespec (05)
108parse_fs_tag db ? ;an000;item tag
109parse_fs_syn dw ? ;an000;synonym pointer
110parse_fs_off dw ? ;an000;offset to filespec
111parse_fs_seg dw ? ;an000;segment of filespec
112
113;======================= switch tables /b ================================
114
115sw_b label byte ;an000;/b switch
116 dw 0000h ;an000;no match flags
117 dw 0000h ;an000;no cap
118 dw dg:switch_res ;an000;result buffer
119 dw dg:noval ;an000;value list/none
120 db 1 ;an000;1 switch
121sw_b_switch db "/B",0 ;an000;/B means ignore CTL-Z
122
123switch_res label byte ;an000;switch result table
124parse_sw_res db ? ;an000;must be string (03)
125parse_sw_tag db ? ;an000;item tag
126parse_sw_syn dw ? ;an000;synonym pointer
127parse_sw_ptr dd ? ;an000;pointer to result
128
129noval label byte ;an000;value table
130 db 0 ;an000;no values
131
132
133;======================= end input parameter control blocks ==============
134
135filespec db 128 dup (0) ;an000;holds filespec
136parse_switch_b db ? ;an000;hold boolean result
137 ; of /b parse
138parse_sw_b db "/B" ;an000;comparison switch
139
140DATA ENDS
141
142DG GROUP CODE,CONST,cstack,DATA
143
144code segment public byte ;an000;code segment
145 assume cs:dg,ds:dg,es:dg,ss:CStack ;an000;
146
147 public parser_command ;an000;share this routine
148
149
150
151;======================= begin main routine ==============================
152.xlist
153
154include parse.asm ;an000;parser
155
156.list
157
158parser_command proc near ;an000;parse routine
159
160 push es ;an000;save registers
161 push ds ;an000;
162 push di ;an000;
163 push si ;an000;
164
165 mov dg:parse_switch_b,false ;an000;init. to false
166 xor cx,cx ;an000;set cx to 0
167 xor dx,dx ;an000;set dx to 0
168 mov di,offset dg:parms ;an000;point to parms
169 mov si,parse_command ;an000;point to ds:81h
170 mov ds,dg:org_ds ;an000;get ds at entry
171 assume ds:nothing ;an000;
172
173parse_continue: ;an000;loop return point
174
175 call sysparse ;an000;invoke parser
176 cmp ax,parse_ok ;an000;is it a good parse
177 jne parse_end ;an000;continue on good parse
178 push si
179 mov si,dx
180 cmp byte ptr es:[si],fs_flag ;an000;do we have a filespec
181; $if e ;an000;yes we do
182 JNE $$IF1
183 call build_fs ;an000;save filespec
184; $else ;an000;
185 JMP SHORT $$EN1
186$$IF1:
187 cmp parse_switch_b,true ;an000;see if already set
188; $if nz ;an000;if not
189 JZ $$IF3
190 call val_sw ;an000;see which switch
191; $else ;an000;
192 JMP SHORT $$EN3
193$$IF3:
194 mov ax,too_many ;an000;set error level
195 jmp parse_end ;an000;exit parser
196; $endif ;an000;
197$$EN3:
198; $endif ;an000;
199$$EN1:
200
201 pop si
202 jmp parse_continue ;an000;continue parsing
203
204parse_end: ;an000;end parse routine
205
206 pop si ;an000;restore registers
207 pop di ;an000; for return to caller
208 pop ds ;an000;
209 assume ds:dg ;an000;
210 pop es ;an000;
211
212 ret ;an000;return to caller
213
214parser_command endp ;an000;end parser_command
215
216
217;======================= subroutine area =================================
218
219
220;=========================================================================
221; build_fs: This routine saves the filespec for use by the calling program.
222;=========================================================================
223
224build_fs proc near ;an000;save filespec
225
226 push ax ;an000;save affected regs.
227 push di ;an000;
228 push si ;an000;
229 push ds ;an000;
230 push es ;an000;
231
232 mov di,offset dg:filespec ;an000;point to filespec buffer
233 lds si,dword ptr es:parse_fs_off ;an000;get offset
234
235build_cont: ;an000;continue routine
236
237 lodsb ;an000;mov ds:si to al
238 cmp al,nul ;an000;is it end of filespec
239; $if nz ;an000;if not
240 JZ $$IF7
241 stosb ;an000;move byte to filespec
242 jmp build_cont ;an000;continue buffer fill
243; $endif ;an000;
244$$IF7:
245 stosb ;an000;save nul
246
247 pop es ;an000;restore regs
248 pop ds ;an000;
249 pop si ;an000;
250 pop di ;an000;
251 pop ax ;an000;
252
253 ret ;an000;return to caller
254
255build_fs endp ;an000;end proc
256
257;=========================================================================
258; val_sw : determines which switch we have.
259;=========================================================================
260
261val_sw proc near ;an000;switch determination
262
263 cmp es:parse_sw_syn,offset es:sw_b_switch ;an000;/B switch?
264; $if e ;an000;compare good
265 JNE $$IF9
266 mov dg:parse_switch_b,true ;an000;signal /B found
267; $else ;an000;
268 JMP SHORT $$EN9
269$$IF9:
270 mov dg:parse_switch_b,false ;an000;signal /B not found
271; $endif ;an000;
272$$EN9:
273
274 ret ;an000;return to caller
275
276val_sw endp ;an000;end proc
277
278
279code ends ;an000;end segment
280 end ;an000;
281 \ No newline at end of file