rdos/kernel/fcb.asm

78 lines
1.2 KiB
NASM

section .text
; set default drive for current process
; IN dl drive number
setdd: push ds
mov ds, [ss:curpsp]
mov [PSPDD], dl
pop ds
ret
; get default drive for current process
; OUT al drive number
getdd: push ds
mov ds, [ss:curpsp]
mov al, [PSPDD]
pop ds
ret
; Load root directory entry
; IN ax number of 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 next file
fnfile: mov ax, [es:bx+FCBDEN]
inc word [es:bx+FCBDEN]
; 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 fnfile
; bail out if end of dir
mov al, [si]
cmp al, 0
je .err
; next if deleted entry
cmp al, 0xE5
je fnfile
clc
ret
.err: stc
ret
; initialize a FCB for directory scanning
open: mov word [es:bx+FCBDEN], 0
.search: call fnfile
mov al, 0xFF
jc .ret
push si
lea di, [bx+1]
mov cx, 11
rep cmpsb
pop si
jne .search
mov al, 0
.ret: ret
putfn: mov cx, 11
.loop: lodsb
call pputc
loop .loop
ret