home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
BUERG
/
NMOVE586.ZIP
/
PARSE.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-01-01
|
3KB
|
194 lines
TITLE PARSE
;Routines
public PARSE,COPYNAME
G GROUP CODE
CODE SEGMENT PUBLIC
ASSUME CS:G, DS:G, ES:G, SS:G
;--------------------------------------------------------------------
PARSE PROC
; This procedure will parse a filename parameter, which may contain wild card
; characters, and place the result at a location specified.
; call: bx -> replacement filename
; si -> full path name to parse which may have wild card characters
; in the last position
; di -> destination of the parsed path name
; return: carry = 1 if an error occurs
; filenam1.ext00 D:\path2\path3\fil??am2.ext0
; ^ ^
; bx si
STRING EQU 1
PATTERN EQU 0
P EQU BX
S EQU SI
D EQU DI
NULL EQU 0
OUTCHARFROM MACRO X, INST1, INST2
IFE X
MOV AH, [P]
ENDIF
MOV [D], AH
INC D
IFNB <INST1>
INST1
ENDIF
IFNB <INST2>
INST2
ENDIF
ENDM
CLD
MOV CX, P
START:
MOV AH, [S]
CMP AH, "*"
JNE S1
OUTCHARFROM PATTERN, <INC P>
JMP WILD
S1:
CMP AH, "\"
JNE S2
OUTCHARFROM STRING, <INC S>
MOV P, CX
JMP SPECIAL
S2:
CMP AH, NULL
JNE S3
MOV S, P
CALL COPYNAME
JMP DONE
S3:
CMP AH, "?"
JNE S4
OUTCHARFROM PATTERN, <INC P>, <INC S>
JMP NORMAL
S4:
OUTCHARFROM STRING, <INC P>, <INC S>
JMP NORMAL
NORMAL:
MOV AH, [S]
CMP AH, "\"
JNE N1
OUTCHARFROM STRING, <INC S>
MOV P, CX
JMP SPECIAL
N1:
CMP AH, "?"
JNE N2
OUTCHARFROM PATTERN, <INC P>, <INC S>
JMP NORMAL
N2:
CMP AH, NULL
JNE N3
OUTCHARFROM STRING
JMP DONE
N3:
CMP AH, ":"
JNE N4
INC CX
CMP P, CX
JNE ERROR
DEC CX
OUTCHARFROM STRING, <INC S>
MOV P, CX
JMP SPECIAL
N4:
CMP AH, "*"
JNE N5
OUTCHARFROM PATTERN, <INC P>
JMP WILD
N5:
CMP AH, "."
JNE N6
OUTCHARFROM STRING, <INC S>
MOV P, CX
N5LOOP:
MOV AH, [P] ; move the P pointer two after the last char. or
INC P ; one after the last "."
CMP AH, "."
JE NORMAL
CMP AH, NULL
JE NORMAL
JMP N5LOOP
N6:
OUTCHARFROM STRING, <INC P>, <INC S>
JMP NORMAL
WILD:
MOV AH, [P]
CMP AH, "."
JNE W1
INC S
JMP NORMAL
W1:
CMP AH, NULL
JNE W2
OUTCHARFROM STRING
JMP DONE
W2:
OUTCHARFROM STRING, <INC P>
JMP WILD
SPECIAL:
MOV AH, [S]
CMP AH, NULL
JNE SP1
MOV S, CX
CALL COPYNAME
JMP DONE
SP1:
JMP NORMAL
ERROR:
STC
MOV AL, 4
RET
DONE:
CLC ; Clear the carry flag
RET
PARSE ENDP
;--------------------------------------------------------------------
COPYNAME PROC
; Copy characters to the given location until after a null has been
; copied.
; call: si -> to the name to be moved
; di -> location to put the name
; cld (up direction)
; returned: si -> one character after the name
; di -> " " " " location
MOVSB
CMP [SI-1], BYTE PTR NULL
JNZ COPYNAME
RET
COPYNAME ENDP
;--------------------------------------------------------------------
CODE ENDS
END