96 lines
1.5 KiB
NASM
96 lines
1.5 KiB
NASM
|
|
; FCB layout
|
|
; 1 byte drive (0=default, 1=A:, 2=B:, ...)
|
|
; 8.3 filename
|
|
; 8.3 filename for rename
|
|
|
|
FCBDEN: equ 23 ; WORD directory entry number
|
|
FCBSIZ: equ 30
|
|
|
|
section .text
|
|
|
|
; auto-complete drive field in fcb
|
|
; also returns the drive number
|
|
; IN es:bx far ptr FCB
|
|
; OUT dl dl (0=A:, 1=B:, 2=C:, ...)
|
|
fcbdrv: mov dl, [es:bx]
|
|
test dl, dl
|
|
jnz .ret
|
|
call getdd
|
|
mov dl, al
|
|
inc dl
|
|
mov [es:bx], dl
|
|
.ret: dec dl
|
|
ret
|
|
|
|
; Load root directory entry
|
|
; IN ax number of directory entry
|
|
; OUT cs:si ptr to directory entry
|
|
lddir: push ax
|
|
mov cl, 4
|
|
shr ax, cl
|
|
xor dx, dx
|
|
call maprd
|
|
; get si to point to entry
|
|
pop si
|
|
mov cl, 5
|
|
shl si, cl
|
|
and si, 0x1FF
|
|
add si, dskbuf
|
|
ret
|
|
|
|
; find first matching file
|
|
; IN ES:BX input fcb
|
|
fndfst: ; get and log in drive
|
|
call fcbdrv
|
|
call logdrv
|
|
; set search state to zero
|
|
push es
|
|
push bx
|
|
call getdta
|
|
xor ax, ax
|
|
mov [es:bx+0x20+1], ax
|
|
pop bx
|
|
pop es
|
|
; find next matching file
|
|
; state is kept in DTA
|
|
fndnxt: ; get net direntry to fetch
|
|
; get number of current entry from DTA
|
|
push es
|
|
push bx
|
|
call getdta
|
|
mov ax, [es:bx+0x20+1]
|
|
inc word [es:bx+0x20+1]
|
|
pop bx
|
|
pop es
|
|
; bail out if we are at end of dir
|
|
cmp ax, [bpb+BPBRDE]
|
|
jnc .err
|
|
; load entry and first byte
|
|
push bx
|
|
call lddir
|
|
pop bx
|
|
; next if hidden, dir or vol label
|
|
test byte [si+0x0B], 0xDA
|
|
jnz fndnxt
|
|
; bail out if end of dir
|
|
mov al, [si]
|
|
cmp al, 0
|
|
je .err
|
|
; next if deleted entry
|
|
cmp al, 0xE5
|
|
je fndnxt
|
|
; compate DS:SI with ES:BX+1
|
|
lea di, [bx+1]
|
|
mov cx, 11
|
|
rep cmpsb
|
|
; try next if mismatch
|
|
jne fndnxt
|
|
clc
|
|
ret
|
|
.err: stc
|
|
ret
|
|
|
|
open:
|
|
ret
|