rdos/kernel/fcb.asm

70 lines
1.3 KiB
NASM

section .bss
; default drive if field in FCB = 0
defdrv: resb 1
section .text
; Functions here generally expect the FCB to be at ES:BX
; Helper function: read the drive number from FCB,
; apply default if necessary,
; and make it current I/O drive
setdrv: mov dl, [es:bx+fcb.drive] ; A=1
test dl, dl
jnz .nofix
mov dl, [defdrv] ; A=0
inc dl
mov [es:bx+fcb.drive], dl ; A=1
; now set as current i/o drive
.nofix: dec dl ; A=0 for dsksel
jmp dsksel
; FCB open
fcbopn: ; call fcbfst
; copy match
; store cluster number in fcb
; record = 0
ret
; FCB close
fcbcls: ; flush disk buffer
ret
; FCB find first
fcbfst: mov word [es:bx+fcb.dirpos], 0
; FCB find next
fcbnxt: call setdrv
; load rootdir sector from state
; search until next match
; next sec & loop if mismatch
; err exit if no further matches
ret
; FCB delete file
fcbdel: ; call fcbfst
; get search state, load root dir from there
; mark file as deleted
; mark buffer dirty
ret
; FCB read
; read sector from cluster into diskbuf
fcbrd: ; read record from sector
; advance record num, carry over to cluster
ret
; FCB write
fcbwr: ; read sector from cluster into diskbuf
; write record into sector
; mark buffer dirty
; advance record num, carry over to cluster
ret
; FCB create
fcbcre:
ret
; FCB rename
fcbren:
ret