📄 rxdosfil.asm
字号:
mov ch, byte ptr es:[ deAttributes ][ bx ]
and ch, ATTR_MASK ; AND (NOT ATTR_READONLY)
test ch, cl ; test for special cases
jnz locByAttrib_42 ; if bit match -->
or cl, cl ; which files ?
jz locByAttrib_22 ; just normal files -->
test cl, (ATTR_HIDDEN + ATTR_SYSTEM + ATTR_DIRECTORY)
jz locByAttrib_18 ; skip normal files -->
locByAttrib_22:
and ch, (not ATTR_READONLY) ; is file a normal file ?
jnz locByAttrib_18 ; normal file filter -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; item found
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locByAttrib_42:
push bx
push word ptr es:[ deDate ][ bx ]
push word ptr es:[ deTime ][ bx ]
push word ptr es:[ deFileSize. _low ][ bx ]
push word ptr es:[ deFileSize. _high ][ bx ]
push word ptr es:[ deAttributes ][ bx ]
lea si, offset deName-1 [ bx ] ; drive here doesn't matter
lea di, offset _tempname [ bp ] ; expand name
saveRegisters es, si, ss, di ; arguments
call convFCBNametoASCIZ ; expand name
pop ax
getdarg ds, di, _findAccess ; point to find access
mov byte ptr [ findFileAttribute ][ di ], al
pop word ptr [ findFileSize. _high ][ di ]
pop word ptr [ findFileSize. _low ][ di ]
pop word ptr [ findFileTime ][ di ]
pop word ptr [ findFileDate ][ di ]
pop word ptr [ findCCBPointer ][ di ]
mov ax, word ptr [ _diskAccess. diskAcPosition. _low ][ bp ]
mov dx, word ptr [ _diskAccess. diskAcPosition. _high ][ bp ]
mov cx, sizeDIRENTRY
call _div32
mov word ptr [ findDirEntry ][ di ], ax
mov ax, word ptr [ _diskAccess. diskAcBegCluster ][ bp ]
mov dx, word ptr [ _diskAccess. diskAcCurCluster ][ bp ]
mov word ptr [ findDirBegCluster ][ di ], ax
mov word ptr [ findDirCurrCluster ][ di ], dx
setDS ss
lea si, [ _tempname + 2 ][ bp ] ; drive doesn't matter
getdarg es, di, _findAccess ; point to find access
lea di, offset findFileName [ di ] ; resultant filename
mov cx, (sizeTempExpandedFCBNAME - 2)
rep movsb ; copy effectively
clc
jmp short locByAttrib_56
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; error exit
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locByAttrib_54:
mov ax, offset pexterrNoMoreFiles
stc
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locByAttrib_56:
restoreSegments
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Return Where in Directory ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ss:di pointer to dir access block ;
; ;
; Output: ;
; dx:ax directory sector ;
; cl offset in items from start of sector ;
; ;
; Assumes ss == ds ;
;...............................................................;
getWhereInDir:
mov ax, word ptr [ fileAcDirOffset ][ di ]
sub ax, ccbData ; adjust for header offset
mov cl, sizeDIRENTRY ; bytes per entry
div cl ; remainder should be zero
mov cx, ax ; return in cl
mov ax, word ptr [ fileAcDirSector. _low ][ di ]
mov dx, word ptr [ fileAcDirSector. _high ][ di ]
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Blank Init Directory Name ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; es:si pointer to dir entry in buffer ;
; ;
;...............................................................;
blankinitDirName:
push di
push cx
push ax
mov di, si
clearMemory sizeFILENAME, ' '
pop ax
pop cx
pop di
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Scan Directory (Exact Search) ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Note: ;
; Subdirectories are implemented as files. That means that ;
; after each sector we must search for the next FAT table ;
; entry to get the next cluster. ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx cluster of dir to search ;
; es:di filename to search ;
; ;
; Output: ;
; if item found: ;
; ax drive ;
; bx attributes ;
; cx file size ;
; dx cluster ;
; es:si pointer to located directory entry ;
; ;
; if item NOT found: ;
; cy if item not found ;
;...............................................................;
scanDirectory:
Entry
ddef _filenamePtr, es, di
defbytes _diskAccess, sizeDISKACCESS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; init access
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setES ss
lea bx, offset _diskAccess [ bp ] ; pointer to access block
call initdiskAccess ; [ax] is drive, [dx] is cluster
call getDPB ; check for media change
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; lookup entry
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setES ss
mov word ptr [ _diskAccess. diskAcPosition. _low ][ bp ], -sizeDIRENTRY
mov word ptr [ _diskAccess. diskAcPosition. _high ][ bp ], -1
mov word ptr [ _diskAccess. diskAcOptions ][ bp ], (ccb_isDIR)
scanDir_36:
add word ptr [ _diskAccess. diskAcPosition. _low ][ bp ], sizeDIRENTRY
adc word ptr [ _diskAccess. diskAcPosition. _high ][ bp ], 0000
lea bx, offset _diskAccess [ bp ] ; pointer to access block
call _FATReadRandom ; read into buffer
stc ; just in case error,
jz scanDir_56 ; if no more data -->
lea di, offset deName[ bx ] ; get pointer to name
cmp byte ptr es:[ di ], DIRENTRY_NEVERUSED
stc ; just in case error,
jz scanDir_56 ; if no more data -->
test byte ptr es:[ deAttributes ][ bx ], ATTR_VOLUME
jnz scanDir_36 ; scan skips volume entries -->
lds si, dword ptr [ _filenamePtr ][ bp ] ; pointer to search file name
call compareDirEntries
jnz scanDir_36 ; if item not found -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; item found
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov si, bx ; dir entry to si
mov dx, word ptr es:[ deStartCluster ][ si ] ; cluster
mov cx, word ptr es:[ deFileSize ][ si ] ; file size
mov bl, byte ptr es:[ deAttributes ][ si ] ; attributes
xor bh, bh ; zero, nc
mov ax, word ptr [ _diskAccess. diskAcDrive ][ bp ]
scanDir_56:
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Compare Entries ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Compare two directory entries. If the Lead character of ;
; source string is E5, it is converted to 05 to help search. ;
; ;
; Input: ;
; ds:si source string (may contain ? character ) ;
; es:di match string (may not contain wild character ) ;
; ;
; Output: ;
; zr entry located ;
;...............................................................;
compareDirEntries:
cmp byte ptr [ si ], DIRENTRY_DELETED ; E5 ?
jnz compareDirEntries_04
mov byte ptr [ si ], SPECIAL_CHAR
compareDirEntries_04:
cmp byte ptr es:[ di ], DIRENTRY_NEVERUSED
jz compareDirEntries_08
cmp byte ptr es:[ di ], DIRENTRY_DELETED
jnz compareDirEntries_12
compareDirEntries_08:
mov al, byte ptr es:[ di ]
cmp al, '.' ; force non zero
ret
compareDirEntries_12:
push di
push si
mov cx, sizeFILENAME
call CompareString ; source / dest compare
pop si
pop di ; restore pointers
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Locate Empty Slot in Directory ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Note: ;
; This will allocate space to any subdirectory except the ;
; root directory itself in order to create additional ;
; directory entries. ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx cluster of dir to search ;
; ;
; Output: ;
; ax drive ;
; es:si pointer to located directory entry ;
; cy if item not found ;
;...............................................................;
LocateFreeDirSlot:
Entry
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -