📄 rxdosdir.asm
字号:
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_splitpath_08:
xor ax, ax ; prev character
mov dx, si
push si
_splitpath_12:
xor cx, cx ; last . separator, if any
_splitpath_16:
mov ah, al ; prev character
mov al, byte ptr [ si ]
inc si
or al, al ; end of string ?
jz _splitpath_28 ; if yes -->
cmp al, '/' ; path separator ?
jz _splitpath_24 ; if yes -->
cmp al, '\' ; path separator ?
jz _splitpath_24 ; if yes -->
cmp al, '?' ; wild character ?
jz _splitpath_26 ; if yes -->
cmp al, '*' ; wild character ?
jz _splitpath_26 ; if yes -->
cmp al, '.' ; extension separator ?
jnz _splitpath_16
cmp ah, '.' ; previous also ..
jz _splitpath_12 ; yes, ignore -->
mov cx, si ; save location of extension
dec cx ; must save dot position
jmp _splitpath_16 ; continue scanning -->
_splitpath_24:
mov dx, si
jmp _splitpath_16
_splitpath_26:
mov byte ptr [ _wildchars ][ bp ], 1
jmp _splitpath_16
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; at end of scan, see if path defined
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_splitpath_28:
pop si ; start of path
storarg _extension, cx ; save pointer to extension
or dx, dx ; path defined (\ in string ?)
jz _splitpath_38 ; no path defined -->
mov cx, dx
sub cx, si ; length of path string
cmp cx, size expPath ; greater than expPath ?
jle _splitpath_30 ; no -->
mov cx, (size expPath) - 1 ; max size
_splitpath_30:
getarg di, _expandedname
lea di, offset [ expPath ][ di ]
rep movsb ; copy path
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy filename
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_splitpath_38:
getarg di, _expandedname
lea di, offset [ expFilename ][ di ]
mov cx, (size expFilename) - 1
mov si, dx ; get start of filename
or si, si ; no filename ?
jz _splitpath_48 ; no -->
_splitpath_40:
lodsb ; get character
or al, al ; if null, no extension -->
jz _splitpath_60
cmp al, '.' ; if period
jz _splitpath_48 ; we have extension -->
stosb
loop _splitpath_40
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy extension
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_splitpath_48:
getarg di, _expandedname
lea di, offset [ expExtension ][ di ]
mov cx, (size expExtension) - 1
getarg si, _extension
or si, si ; no filename ?
jz _splitpath_60 ; no -->
_splitpath_50:
lodsb ; get character
or al, al ; if null, no extension -->
jz _splitpath_60
stosb
loop _splitpath_50
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; done
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_splitpath_60:
mov al, byte ptr [ _wildchars ][ bp ]
or al, al
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Make Path ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; si points to expanded name area ;
; di points to filename to build ;
;...............................................................;
_makePath:
push si
push di
mov dx, si
mov byte ptr [ di ], 00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; insert drive
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lea bx, offset [ expDrive ][ si ]
mov al, byte ptr [ bx ]
or al, al ; drive available ?
jz _makePath_08 ; no -->
mov ah, ':'
stosw ; store drive
mov byte ptr [ di ], 00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; insert path
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_makePath_08:
lea si, offset [ expPath ][ si ]
mov al, byte ptr [ si ]
or al, al ; path available ?
jz _makePath_16 ; no -->
call _CopyString ; copy path to output
dec di ; backup over null term
cmp byte ptr [ di-1 ], '\' ; path ended in \ ?
jz _makePath_16 ; no -->
mov ax, '\'
stosb ; add \
mov byte ptr [ di ], 00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; insert filename
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_makePath_16:
mov si, dx
lea si, offset [ expFilename ][ si ]
mov al, byte ptr [ si ]
or al, al ; filename available ?
jz _makePath_24 ; no -->
call _CopyString ; copy filename to output
dec di ; backup over null term
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; insert extension
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_makePath_24:
mov si, dx
lea si, offset [ expExtension ][ si ]
mov al, byte ptr [ si ]
or al, al ; filename available ?
jz _makePath_32 ; no -->
call _CopyString ; copy filename to output
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_makePath_32:
pop di
pop si
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Directory ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; ss:di Arg Array ;
; ax Number of arguments in array ;
;...............................................................;
_Dir:
Entry
def _currdisk
def _maxdisk
def _filesread
def _extensionFlag
ddef _freespace
ddef _totalfilespace
def __argarray, di ; arg array
defbytes _asciiFileTime, 20
defbytes _asciiFileDate, 20
defbytes _pathname, 128 ; search pathname
defbytes _filename, 128 ; search filename
defbytes _expandedname, sizeExpandedName
defbytes _printbuffer, 128
xor ax, ax
mov word ptr [ _filesread ][ bp ], ax
mov word ptr [ _totalfilespace. _low ][ bp ], ax
mov word ptr [ _totalfilespace. _high ][ bp ], ax
mov cx, 0000 ; min args
mov dx, 0001 ; max args
mov bx, offset _DirSwitches ; dir switches
call PreProcessCmndLine ; process switches and args
ifc _dir_Exit ; if error -->
mov ax, word ptr [ _DirPauseSwitch. swFlags ]
call setPagingMode
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get current, max disks
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int21 CurrentDisk ; get current disk
mov dl, al
inc al ; a=1, ...
storarg _currdisk, ax ; save disk letter
Int21 SelectDisk ; use select disk to get max
storarg _maxdisk, ax ; save max disk letter
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if no args, create a *.* arg
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov di, word ptr [ __argarray ][ bp ]
mov si, word ptr [ di ] ; locate dir argument
or si, si ; no name provided ?
jnz _dir_06 ; name provided -->
mov si, offset RxDOS_AllFiles ; dummy path
_dir_06:
lea di, offset [ _pathname ][ bp ]
call _CopyString ; copy whatever was entered
_dir_08:
dec di ; backup over null
cmp byte ptr [ di-1 ], ' ' ; only entered drive and colon ?
jz _dir_08 ; no -->
cmp byte ptr [ di-1 ], ':' ; only entered drive and colon ?
jnz _dir_10 ; no -->
mov si, offset RxDOS_AllFiles ; dummy path
call _CopyString ; append all files
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; is name a directory ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_dir_10:
lea si, offset [ _pathname ][ bp ]
lea di, offset [ _expandedname ][ bp ]
call _splitpath
mov al, byte ptr [ _expandedname. expDrive ][ bp ]
or al, al ; if no drive specified
jz _dir_14 ; continue -->
call _testDriveLetter ; is drive letter 'a' - 'z' ?
ifc _dir_DriveError ; no, bad drive -->
cmp al, byte ptr [ _maxdisk ][ bp ] ; is it greater than max drive ?
jc _dir_14 ; if valid drive
jmp _dir_DriveError ; yes, bad drive -->
_dir_14:
mov al, byte ptr [ _expandedname. expExtension ][ bp ]
mov byte ptr [ _extensionFlag ][ bp ], al ; save whether extension was ever present
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -