📄 rxdosfil.asm
字号:
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get next name
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_20:
setES ss
lea di, offset _tempFileName [ bp ] ; pointer to temp name
lds si, dword ptr [ _endfilenamePointer ][ bp ]
call skipToNextName ; skip to starting name
storarg _begfilenamePointer, si ; save starting pointer
call convFilenametoFCBString ; convert to a match template
jnz locateFile_24 ; if name is not blank -->
test word ptr _options [ bp ], FILECANNOT_BEDIRECTORY
ifnz locateFile_FileNotFound ; if cannot be a directory -->
jmp locateFile_56 ; else return what we have so far -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; scan for wild characters
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_24:
stordarg _endfilenamePointer, ds, si
mov word ptr [ _terminatingChar ][ bp ], ax
setES ss
lea di, offset _tempFileName [ bp ] ; pointer to temp name
mov cx, sizeTempFILENAME - 1 ; count
mov al, '?'
repnz scasb ; scan for wild characters
jnz locateFile_26 ; if no wild chars found -->
cmp byte ptr [ _terminatingChar ][ bp ], '\'
ifz locateFile_PathNotFound ; inside path def, error -->
cmp byte ptr [ _terminatingChar ][ bp ], '/'
ifz locateFile_PathNotFound ; inside path def, error -->
test word ptr _options [ bp ], FILEHAS_WILDCHARS
ifz locateFile_FileNotFound ; if wild chars NOT allowed -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; see if entry is a device name
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_26:
currSegment ds, es ; set to seg address
lea si, offset _tempFileName [ bp ] ; search es: si
call getDevice ; determine if it's a device name
ifc locateFile_32 ; if not a device name -->
; here if device name
cmp byte ptr [ _terminatingChar ][ bp ], '\' ; was name part of path ?
ifz locateFile_PathNotFound ; inside path def, error -->
cmp byte ptr [ _terminatingChar ][ bp ], '/' ; was name part of path ?
ifz locateFile_PathNotFound ; inside path def, error -->
; test word ptr _options [ bp ], FILEHAS_NOFILENAME ; if no filename, then definetly
; ifz locateFile_PathNotFound ; inside path def, error -->
test word ptr _options [ bp ], FILE_NODEVICENAME; else if in filename, it is allowed ?
ifnz locateFile_FileNotFound ; error if no device names allowed -->
clc ; if NO error
mov si, word ptr [ _dirLocate. _pointer ][ bp ]
mov word ptr ss:[ fileAcDevicePtr. _segment ][ si ], es
mov word ptr ss:[ fileAcDevicePtr. _pointer ][ si ], bx
mov ax, 8000h
jmp locateFile_60
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; scan for path in directory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_32:
currSegment ds, es
lea di, offset _tempFileName [ bp ] ; search es: di
mov ax, word ptr [ _drive ][ bp ] ; get drive
mov dx, word ptr [ _cluster ][ bp ] ; cluster to search next
mov word ptr [ _dirCluster ][ bp ], dx ; start cluster of directory
locateFile_36:
call scanDirectory ; scan for name in directory
jnc locateFile_48 ; if an item was found -->
cmp byte ptr [ _terminatingChar ][ bp ], '\'
jz locateFile_PathNotFound ; inside path def, error -->
cmp byte ptr [ _terminatingChar ][ bp ], '/'
jz locateFile_PathNotFound ; inside path def, error -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; entry not found or matched.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
or word ptr [ _drive ][ bp ], 8000h ; not found.
test word ptr _options [ bp ], (FILECANNOT_BEDEFINED + FILEMAY_EXIST)
jnz locateFile_56 ; if not defined is ok -->
jmp short locateFile_FileNotFound ; not found -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; is FOUND entry a filename ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_48:
mov word ptr [ _cluster ][ bp ], dx ; cluster to search next
test bx, (ATTR_VOLUME + ATTR_DIRECTORY) ; is entry a directory ?
jnz locateFile_50 ; if not a file -->
cmp byte ptr [ _terminatingChar ][ bp ], '\'
jz locateFile_PathNotFound ; if path expected, error -->
cmp byte ptr [ _terminatingChar ][ bp ], '/'
jz locateFile_PathNotFound ; if path expected, error -->
test word ptr _options [ bp ], (FILECANNOT_BEDEFINED + FILEHAS_NOFILENAME)
jnz locateFile_AccessDenied ; if access denied -->
jmp short locateFile_Return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; is FOUND entry a directory ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_50:
test bx, ATTR_DIRECTORY ; is item a directory ?
jz locateFile_FileNotFound ; if not, its an error -->
cmp byte ptr [ _terminatingChar ][ bp ], '\'
ifz locateFile_20 ; if path expected, get next -->
cmp byte ptr [ _terminatingChar ][ bp ], '/'
ifz locateFile_20 ; if path expected, get next -->
test word ptr _options [ bp ], FILECANNOT_BEDIRECTORY
jnz locateFile_FileNotFound ; if cannot be a directory -->
test word ptr _options [ bp ], FILECANNOT_BEDEFINED
jz locateFile_Return ; if everything is ok -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; in case of error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_FileNotFound:
SetError pexterrFileNotFound, locateFile_60
locateFile_PathNotFound:
SetError pexterrPathNotFound, locateFile_60
locateFile_AccessDenied:
SetError pexterrAccessDenied, locateFile_60
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_Return:
call locateCCBPHeader ; si dir pointer/ di ccb
mov bx, word ptr [ _dirLocate. _pointer ][ bp ]
mov word ptr [ fileAcBufferPtr. _segment ][ bx ], es
mov word ptr [ fileAcBufferPtr. _pointer ][ bx ], di
mov word ptr [ fileAcDirOffset ][ bx ], cx ; offset in dir sector
mov ax, word ptr es:[ ccbLBN. _low ][ di ]
mov dx, word ptr es:[ ccbLBN. _high ][ di ]
mov word ptr [ fileAcDirSector. _low ][ bx ], ax; which dir sector
mov word ptr [ fileAcDirSector. _high ][ bx ], dx
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; exit
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_56:
mov bx, word ptr [ _dirLocate. _pointer ][ bp ] ; restore bx
mov dx, word ptr [ _cluster ][ bp ] ; cluster
mov ax, word ptr [ _drive ][ bp ] ; drive
mov word ptr [ fileAcCluster ][ bx ], dx
mov word ptr [ fileAcDrive ][ bx ], ax
mov cx, word ptr [ _dirCluster ][ bp ] ; start cluster of directory
mov word ptr [ fileAcDirCluster ][ bx ], cx
clc
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; exit
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_60:
push ax
currSegment ds
mov bx, word ptr [ _dirLocate. _pointer ][ bp ]
mov ax, word ptr [ _begfilenamePointer ][ bp ]
mov word ptr [ fileAcNameOffset ][ bx ], ax
mov ax, word ptr [ _drive ][ bp ] ; drive
mov word ptr [ fileAcDrive ][ bx ], ax
pop ax
pop ds
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Locate File by Attribute ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; (important: starts search at offset in 'findDirEntry') ;
; ;
; es:di pointer to find access block (DTA area) ;
;...............................................................;
LocateFileByAttribute:
Entry
def _attributes
ddef _findAccess, es, di
defbytes _diskAccess, sizeDISKACCESS
defbytes _tempname, sizeTempExpandedFCBNAME
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; init access
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
saveSegments
getdarg es, di, _findAccess ; point to find access
xor ah, ah
mov al, byte ptr es:[ findSrchDrive ][ di ]
mov dx, word ptr es:[ findDirBegCluster ][ di ]
mov cl, byte ptr es:[ findSrchAttributes][ di ]
and cl, ATTR_MASK
mov byte ptr [ _attributes ][ bp ], cl ; save for fast search
setES ss
lea bx, offset _diskAccess [ bp ] ; pointer to access block
call initdiskAccess ; [ax] is drive, [dx] is cluster
call getAddrDPB ; see if drive initialized
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; lookup entry
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getdarg es, di, _findAccess ; point to find access
mov cx, sizeDIRENTRY
mov ax, word ptr es:[ findDirEntry ][ di ]
cmp ax, -1
jnz locByAttrib_14
xor ax, ax
mov word ptr es:[ findDirEntry ][ di ], ax
locByAttrib_14:
mul cx
sub ax, sizeDIRENTRY ; (not same as dec ax before mult)
sbb dx, 0000 ; just adjust for next loop
mov word ptr [ _diskAccess. diskAcPosition. _low ][ bp ], ax
mov word ptr [ _diskAccess. diskAcPosition. _high ][ bp ], dx
mov word ptr [ _diskAccess. diskAcOptions ][ bp ], (ccb_isDIR)
locByAttrib_18:
setDS ss ; insure ds == ss
lea bx, offset _diskAccess [ bp ] ; pointer to access block
add word ptr [ diskAcPosition. _low ][ bx ], sizeDIRENTRY
adc word ptr [ diskAcPosition. _high ][ bx ], 0000
call _FATReadRandom ; read into buffer
ifz locByAttrib_54 ; if no more data -->
lea di, offset deName[ bx ] ; get pointer to name
cmp byte ptr es:[ di ], DIRENTRY_NEVERUSED
ifz locByAttrib_54 ; if no more data -->
cmp byte ptr es:[ di ], DIRENTRY_DELETED
jz locByAttrib_18 ; don't bother -->
lds si, dword ptr [ _findAccess ][ bp ] ; pointer to search file name
lea si, offset findSrchName[ si ] ;
call compareDirEntries
jnz locByAttrib_18 ; if item not found -->
mov cl, byte ptr [ _attributes ][ bp ] ; template attributes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -