]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/EDLIN/EDLPARSE.ASM
3 title EDLPARSE for EDLIN
6 ;******************* START OF SPECIFICATIONS *****************************
8 ; MODULE NAME: EDLPARSE.SAL
10 ; DESCRIPTIVE NAME: PARSES THE EXTERNAL COMMAND LINE FOR EDLIN
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).
16 ; ENTRY POINT: PARSER_COMMAND
18 ; INPUT: DOS COMMAND LINE
20 ; EXIT NORMAL: AX = 0FFH - VALID SWITCH AND FILESPEC SPECIFIED
22 ; EXIT ERROR: AX NOT= 0FFH - INVALID SWITCH OR NO FILESPEC SPECIFIED
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
31 ; EXTERNAL REFERENCES:
33 ; ROUTINE: PARSE.ASM - THIS IS THE PARSER CODE.
35 ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
36 ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
40 ; AN000 VERSION 4.00 - IMPLEMENTS THE SYSTEM PARSER (SYSPARSE)
42 ; COPYRIGHT: "THE IBM PERSONAL COMPUTER EDLIN UTILITY"
43 ; "VERSION 4.00 (C) COPYRIGHT 1988"
44 ; "LICENSED MATERIAL - PROPERTY OF Microsoft"
47 ;******************** END OF SPECIFICATIONS ******************************
50 ;======================= equates for edlparse ============================
52 parse_ok equ
0 ;an000;good parse return
53 parse_command equ
081h ;an000;offset of command line
55 fs_flag equ
05h ;an000;filespec found
56 sw_flag equ
03h ;an000;switch found
57 true equ
0ffffh ;an000;true
58 false equ
00h ;an000;false
59 too_many equ
01h ;an000;too many parms
61 ;======================= end equates =====================================
64 CODE SEGMENT PUBLIC BYTE
67 CONST
SEGMENT PUBLIC BYTE
73 DATA SEGMENT PUBLIC BYTE
76 extrn org_ds
:word ;an000; dms;
78 public parse_switch_b
;an000;parse switch result
79 public filespec
;an000;actual filespec
81 ;======================= input parameters control blocks =================
82 ; these control blocks are used by sysparse and must be pointed to by
83 ; es:di on invocation.
85 public parms
;an000;share parms
86 parms
label byte ;an000;parms control block
87 dw dg
:parmsx
;an000;point to parms structure
88 db 00h ;an000;no additional delims.
90 parmsx
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
97 ;======================= filespec positional tables ======================
99 fs_pos
label byte ;an000;filespec positional
100 dw 0200h ;an000;filespec/not optional
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.
106 filespec_res
label byte ;an000;filespec result table
107 parse_fs_res db ?
;an000;must be filespec (05)
108 parse_fs_tag db ?
;an000;item tag
109 parse_fs_syn dw ?
;an000;synonym pointer
110 parse_fs_off dw ?
;an000;offset to filespec
111 parse_fs_seg dw ?
;an000;segment of filespec
113 ;======================= switch tables /b ================================
115 sw_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
121 sw_b_switch db "/B",0 ;an000;/B means ignore CTL-Z
123 switch_res
label byte ;an000;switch result table
124 parse_sw_res db ?
;an000;must be string (03)
125 parse_sw_tag db ?
;an000;item tag
126 parse_sw_syn dw ?
;an000;synonym pointer
127 parse_sw_ptr dd ?
;an000;pointer to result
129 noval
label byte ;an000;value table
130 db 0 ;an000;no values
133 ;======================= end input parameter control blocks ==============
135 filespec db 128 dup (0) ;an000;holds filespec
136 parse_switch_b db ?
;an000;hold boolean result
138 parse_sw_b db "/B" ;an000;comparison switch
142 DG GROUP
CODE,CONST
,cstack
,DATA
144 code segment public byte ;an000;code segment
145 assume
cs:dg
,ds:dg
,es:dg
,ss:CStack
;an000;
147 public parser_command
;an000;share this routine
151 ;======================= begin main routine ==============================
154 include parse
.asm
;an000;parser
158 parser_command proc
near ;an000;parse routine
160 push es ;an000;save registers
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;
173 parse_continue: ;an000;loop return point
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
180 cmp byte ptr es:[si],fs_flag
;an000;do we have a filespec
181 ; $if e ;an000;yes we do
183 call build_fs
;an000;save filespec
187 cmp parse_switch_b
,true
;an000;see if already set
188 ; $if nz ;an000;if not
190 call val_sw
;an000;see which switch
194 mov ax,too_many
;an000;set error level
195 jmp parse_end
;an000;exit parser
202 jmp parse_continue
;an000;continue parsing
204 parse_end: ;an000;end parse routine
206 pop si ;an000;restore registers
207 pop di ;an000; for return to caller
212 ret ;an000;return to caller
214 parser_command endp
;an000;end parser_command
217 ;======================= subroutine area =================================
220 ;=========================================================================
221 ; build_fs: This routine saves the filespec for use by the calling program.
222 ;=========================================================================
224 build_fs proc
near ;an000;save filespec
226 push ax ;an000;save affected regs.
232 mov di,offset dg
:filespec
;an000;point to filespec buffer
233 lds si,dword ptr es:parse_fs_off
;an000;get offset
235 build_cont: ;an000;continue routine
237 lodsb ;an000;mov ds:si to al
238 cmp al,nul
;an000;is it end of filespec
239 ; $if nz ;an000;if not
241 stosb ;an000;move byte to filespec
242 jmp build_cont
;an000;continue buffer fill
245 stosb ;an000;save nul
247 pop es ;an000;restore regs
253 ret ;an000;return to caller
255 build_fs endp
;an000;end proc
257 ;=========================================================================
258 ; val_sw : determines which switch we have.
259 ;=========================================================================
261 val_sw proc
near ;an000;switch determination
263 cmp es:parse_sw_syn
,offset
es:sw_b_switch
;an000;/B switch?
264 ; $if e ;an000;compare good
266 mov dg
:parse_switch_b
,true
;an000;signal /B found
270 mov dg
:parse_switch_b
,false
;an000;signal /B not found
274 ret ;an000;return to caller
276 val_sw endp
;an000;end proc
279 code ends
;an000;end segment