📄 rxdosstr.asm
字号:
; es:di match string (may not contain wild character ) ;
; cx count ;
;...............................................................;
CompareString:
rep cmpsb ; match ?
jz compareString_16 ; yes, continue if not zero -->
mov al, byte ptr [si - 1]
cmp al, questionMark ; previous a wild character ?
jnz compareString_16 ; if not ? wild character -->
or cx, cx
jnz compareString ; else continue matching -->
ret
compareString_16:
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Copy String ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; stack source string address ;
; stack dest string address ;
; ;
; Returns: ;
; es:di points to null terminator of dest string. ;
;...............................................................;
CopyString:
Entry 4
darg _srcstring
darg _dststring
saveRegisters ds, si, ax
getdarg ds, si, _srcstring
getdarg es, di, _dststring
CopyString_08:
lodsb
stosb
or al, al
jnz CopyString_08
dec di
restoreRegisters ax, si, ds
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Copy Block ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; stack source string address ;
; stack dest string address ;
; cx length ;
;...............................................................;
CopyBlock:
Entry 4
darg _src
darg _dest
saveSegments di, si
getdarg ds, si, _src
getdarg es, di, _dest
rep movsb
restoreSegments si, di
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Compute String Length ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; stack string address ;
; ;
; Output: ;
; cx string length ;
;...............................................................;
StringLength:
Entry 2
darg _string
push es
push di
push ax
xor al, al
mov cx, -1
getdarg es, di, _string
repnz scasb
not cx
dec cx
or cx, cx
pop ax
pop di
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Conditional String Length ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; stack string address ;
; cx max string length to scan ;
; ;
; Output: ;
; cx actual string length ;
; al character just before null ;
; zr/nz if string terminates with null ;
;...............................................................;
condStringLength:
Entry 2
darg _string
push es
push di
push bx
xor al, al
mov bx, cx ; orig length to bx
getdarg es, di, _string ; where to search
repnz scasb ; scan for null
pushf ; zr means we have located a null
sub cx, bx
neg cx ; -length
dec cx ; minus the null
mov al, byte ptr es:[ di - 2 ] ; character just before null
popf ; return status
pop bx
pop di
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Fix Pattern Match ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; If * in pattern matching filenames is the last character in ;
; either the filename or extension, we can convert the pattern ;
; to a simple question filled pattern. If the pattern is not ;
; converted, the NZ flag is returned. ZR is returned if the ;
; pattern has been converted or if there was no conversion ;
; necessary. ;
; ;
; This function will also convert a filename from (text.ext) ;
; to space padded (8 + 3 ) format. ;
; ;
; Input: ;
; ds:si source string (null terminated) ;
; es:di output string ;
; ;
; Output: ;
; ds:si points to terminator found in source string ;
; es:di points to output string ;
; zr filename is all blank ;
;...............................................................;
convFilenametoFCBString:
push di ; save original pointers
mov al, ' '
mov cx, sizeFILENAME ; max filename field length
rep stosb ; blank fill
pop di
push di ; save original pointers
call skipToNextName ; skip to starting name
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; see if special cases . and ..
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp word ptr [ si ], '.' ; special case of just . filename ?
jz convFilenametoFCBString_08 ; yes -->
cmp word ptr [ si ], '..' ; special case of just .. filename ?
jnz convFilenametoFCBString_12 ; no -->
cmp byte ptr [ si + 2 ], 0 ; must be ..[0]
jnz convFilenametoFCBString_12 ; no -->
convFilenametoFCBString_08:
lodsb ; get next
or al, al ; end of string
jz convFilenametoFCBString_14 ; yes -->
stosb ; save period
jmp convFilenametoFCBString_08 ; continue copy -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; presumably normal filename
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
convFilenametoFCBString_12:
mov cx, sizeFILENAME ; max filename field length
call __convfilename ; get name
jnz convFilenametoFCBString_14 ; if not followed by a period -->
add di, sizefnName
mov cx, sizefnExtension ; max extension field length
call __convfilename ; get extension
convFilenametoFCBString_14:
pop di
cmp byte ptr es:[ di ], ' ' ; if entire name is blank
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Grab/ fill filename characters ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ds:si source string (null terminated) ;
; es:di output string ;
; ;
; Output: ;
; zr means dot following name term encountered ;
;...............................................................;
__convfilename:
push di
__convfilename_04:
lodsb ; get character
or al, al
jz __convfilename_26 ; null is end of name -->
cmp al, ' '
jz __convfilename_04 ; null is end of name -->
cmp al, '/'
jz __convfilename_28 ; '\' is end of name -->
cmp al, '\'
jz __convfilename_28 ; '\' is end of name -->
cmp al, '.'
jz __convfilename_28 ; period is end of name -->
cmp al, ','
jz __convfilename_28 ; comma is end of name -->
cmp al, ';'
jz __convfilename_28 ; semicolon is end of name -->
cmp al, ':'
jz __convfilename_28 ; colon is end of name -->
cmp al, '*'
jz __convfilename_12 ; '*' requires expansion -->
call upperCase
stosb ; else just copy
loop __convfilename_04
jmp short __convfilename_20
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; asterisk fill
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__convfilename_12:
mov al, questionMark
rep stosb
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; keep scanning until end of field
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__convfilename_20:
lodsb ; get character
or al, al
jz __convfilename_26 ; null is end of name -->
cmp al, ' '
jz __convfilename_20 ; null is end of name -->
cmp al, '\'
jz __convfilename_28 ; '\' is end of name -->
cmp al, '/'
jz __convfilename_28 ; '/' is end of name -->
cmp al, '.'
jz __convfilename_28 ; period is end of name -->
cmp al, ','
jz __convfilename_28 ; comma is end of name -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -