rdos/kernel/fcb.asm
2019-10-16 21:09:31 +00:00

72 lines
1.6 KiB
NASM

; diskbuf needs to be defined
; User-accessible part of FCB (12 bytes)
fcb_drv: equ 0 ; 1 byte, 1=A: 2=B: 3=C:
fcb_fn: equ 1 ; 8 bytes
fcb_ext: equ 9 ; 3 bytes
; Drive & FS data (6 bytes)
fcb_spt: equ 12 ; byte sectors per track
fcb_nos: equ 13 ; byte number of sides/heads
fcb_ss: equ 14 ; byte sector size: 0=128, 1=256, 2=512, ...
fcb_cs: equ 15 ; byte cluster size: 0=128, 1=256, 2=512, ...
fcb_co: equ 16 ; word start sector for theoretical cluster 0
; Read/Write pointer (6 bytes)
fcb_left: equ 18 ; word number of bytes left to read in current sector
fcb_off: equ 20 ; dword offset in disk (not in file)
; Link to directory item (4 bytes)
fcb_ds: equ 24 ; dword offset of directory item
fcb_end: equ 32
fcb_open_rootdir:
mov dl, 0x01
or dl, 0x80
mov [bx], dl
dec dl
; Setup default data
; Default 2 heads, 9 sectors
mov word [bx+fcb_spt], 0x0209
xor ax, ax
xor dx, dx
lea di, [bx+fcb_ss]
; Sector & Cluster size 128 bytes
mov cx, (fcb_end - fcb_ss)
rep stosb
; load first sector
call drive_read
; copy sector size
mov ax, [diskbuf + fdc_ss]
call log2
sub ax, 7
; ... save as sector size
mov byte [bx+fcb_ss], al
; copy cluster size
xor ah, ah
mov al, [diskbuf + 0x0D]
call log2
add al, [bx+fcb_ss]
mov byte [bx+fcb_cs], al
; copy sectors per track
mov al, [diskbuf + fdc_spt]
mov byte [bx+fcb_spt], al
; copy number of heads/sides
mov al, [diskbuf + 0x1A]
mov byte [bx+fcb_nos], al
xor dx, dx
mov ax, [diskbuf + fdc_sf]
mul byte [diskbuf + fdc_fn]
add ax, [diskbuf + fdc_rsc]
int3
ret