WIP on fcb io

This commit is contained in:
Nero 2019-10-14 17:59:48 +00:00
parent a65f54b121
commit 66f54f639c
4 changed files with 21 additions and 41 deletions

View File

@ -46,8 +46,18 @@ drive_read:
dec dl
mov ax, 0x0201
mov bx, diskbuf
; try read
int 0x13
.giveup:
jnc .end
; reset disk
mov ah, 0x00
int 0x13
; loop with si
dec si
test si, si
jnz .try
stc
.end:
pop si
pop bx
pop dx
@ -57,27 +67,3 @@ drive_read:
.fast: ; fast lane for boot sector
inc cl
jmp .try
.fail:
; reset disk
mov ah, 0x00
int 0x13
; loop with si
dec si
test si, si
jnz .try
stc
jmp .giveup
; Seek to fcb_off given in a ptr
; IN BX ptr to FCB
drive_seek:
push ax
push cx
mov cl, [bx+fcb_ss]
add cl, 7
mov ax, 1
sal ax, cl
int3
pop cx
pop ax
ret

View File

@ -7,11 +7,7 @@ exec:
mov bx, sp
call fcb_parse
call fcb_open_blockdev
mov cx, 5
.loop:
call fcb_getc
loop .loop
call fcb_open_rootdir
add sp, 0x20
pop bx

View File

@ -1,3 +1,5 @@
; diskbuf needs to be defined
; User-accessible part of FCB (12 bytes)
%define fcb_drv 0 ; 1 byte, 1=A: 2=B: 3=C:
%define fcb_fn 1 ; 8 bytes
@ -19,16 +21,18 @@
%define fcb_end 32
fcb_open_blockdev:
fcb_open_rootdir:
mov dl, 0x01
mov [bx], dl
dec dl
; Init non-user FCB data with zero
; Setup default data
; Default 2 heads, 9 sectors
mov word [bx+fcb_spt], 0x0209
xor ax, ax
xor dx, dx
lea di, [bx+fcb_spt]
mov cx, (fcb_end - fcb_spt)
lea di, [bx+fcb_ss]
; Sector & Cluster size 128 bytes
mov cx, (fcb_end - fcb_ss)
rep stosb
; load first sector
@ -72,7 +76,6 @@ fcb_get_sector_mask:
fcb_getc:
push bx
call drive_seek
call fcb_get_sector_mask
not ax
and ax, [bx+fcb_off]

View File

@ -8,11 +8,6 @@ cpu 8086
%define stack (diskbuf)
; Metadata for current disk sector
%define diskptr 0x50
%define disknum 0x54
%define diskflg 0x55
%define default_drive BYTE [0x4]
org self