Build drive selection logic for FCBs

This commit is contained in:
Nero 2020-10-13 20:10:23 +00:00
parent 4e779c5a22
commit c41782c78f
4 changed files with 51 additions and 14 deletions

View File

@ -3,6 +3,7 @@
%include "inc/bpb.asm"
%include "inc/mbr.asm"
%include "inc/fcb.asm"
; kernel stack size in words
%define stacksize 512
@ -22,18 +23,30 @@ print_banner: mov si, banner
cmp al, 0x0D
jnz .loop
cmp dl, 0x80
jc .k
sub dl, (0x80-2)
.k: mov [defdrv], dl
call dskrst
mov dl, 0
call dsksel
mov bx, testfcb
call fcbfst
hlt: hlt
jmp hlt
%include "kernel/fcb.asm"
%include "kernel/drive.asm"
section .data
%defstr VERSIONSTR VERSION
banner: db "RDOS ", VERSIONSTR, 0x0A, 0x0D
%include "kernel/drive.asm"
testfcb: db 0
db "HELLO ", "COM"
times 30 db 0
section .bss

10
inc/fcb.asm Normal file
View File

@ -0,0 +1,10 @@
struc fcb
.drive resb 1
.filename resb 8
.type resb 3
.fn2 resb 8
.tp2 resb 3
.dirpos resw 1
.cluster resw 1
.recordnum resb 1
endstruc

View File

@ -1,6 +1,6 @@
section .bss
; drive selected for I/O
; drive actually selected for I/O
dsknum: resb 1
; current sector number
dskseek: resd 1

View File

@ -1,8 +1,23 @@
; in FCB required
; word offset in rootdir
; used for search
; word current cluster
; byte record num in cluster
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
@ -16,12 +31,10 @@ fcbcls: ; flush disk buffer
ret
; FCB find first
fcbfst: ; init search state in FCB
; jmp to fcbnxt
ret
fcbfst: mov word [es:bx+fcb.dirpos], 0
; FCB find next
fcbnxt: ; load rootdir sector from state
fcbnxt: call setdrv
; load rootdir sector from state
; search until next match
; next sec & loop if mismatch
; err exit if no further matches
@ -31,6 +44,7 @@ fcbnxt: ; load rootdir sector from state
fcbdel: ; call fcbfst
; get search state, load root dir from there
; mark file as deleted
; mark buffer dirty
ret
; FCB read