rdos/kernel/fcb.asm
2019-10-08 19:53:41 +00:00

58 lines
1.4 KiB
NASM

; User-accessible part of FCB (12 bytes)
%define fcb_drv 0 ; 1 byte
%define fcb_fn 1 ; 8 bytes
%define fcb_ext 9 ; 3 bytes
; Drive & FS data (4 bytes)
%define fcb_spt 12 ; byte sectors per track
%define fcb_nos 13 ; byte number of sides/heads
%define fcb_ss 14 ; byte sector size: 2^ss
%define fcb_cs 15 ; byte cluster size: 2^(ss+cs)
; Read/Write pointer (12 bytes):
; Will be overwritten by new filename for CL=17
%define fcb_fsize 16 ; dword file size
%define fcb_fptr 20 ; dword handle position
%define fcb_clus 24 ; word current cluster fptr points in
%define fcb_co 26 ; word start sector for theoretical cluster 0
; Link to directory item (3 bytes)
%define fcb_ds 28 ; word directory sector
%define fcb_do 30 ; byte directory offset
fcb_open_rootdir:
cmp byte [bx], 0
jne .drivedone
mov al, default_drive
mov [bx], al
.drivedone:
mov dl, [bx]
dec dl
xor ax, ax
xor dx, dx
; set directory sector to 0 (=rootdir)
mov [bx+fcb_ds], ax
; load first sector
call drive_read
; transfer sector size
mov ax, [diskbuf + 0x0B]
call log2
mov byte [bx+fcb_ss], al
; transfer cluster size
mov al, [diskbuf + 0x0D]
call log2
mov byte [bx+fcb_cs], al
; transfer sectors per track
mov al, [diskbuf + 0x18]
mov byte [bx+fcb_spt], al
; transfer number of heads/sides
mov al, [diskbuf + 0x1A]
mov byte [bx+fcb_nos], al
ret