rdos/kernel/fcb.asm

60 lines
1023 B
NASM
Raw Permalink Normal View History

2021-01-21 23:28:57 +01:00
; FCB layout
2021-03-19 19:50:50 +01:00
struc FCB
FCBDRV resb 1 ; BYTE drive (0=default, 1=A:, 2=B:, ...)
FCBFN resb 11 ; 11 BYTES filename
FCBCLUS resw 1 ; DWORD current cluster
FCBRN resb 1 ; BYTE record in cluster
endstruc
FCBSIZ equ FCB_size
section .data
defdrv db 0
dta dd 0
2021-01-21 23:28:57 +01:00
section .text
2021-01-23 18:32:53 +01:00
; auto-complete drive field in fcb
; also logs in the drive
; IN ds:dx far ptr FCB
fcbdrv push ds
push dx
mov si, dx
; if currently zero, ...
mov dl, [si] ; 1-based
2021-01-23 18:32:53 +01:00
test dl, dl
jnz .log
; replace with current drive
mov dl, [cs:defdrv] ; 0-based
2021-01-23 18:32:53 +01:00
inc dl
mov [si], dl ; 1-based
.log dec dl
mov ax, cs
mov ds, ax
call logdrv ; 0-based
pop dx
pop ds
; if carry flag set, resume stack at bp
; this instant-returns some higher level procs
jnc .ret
mov sp, bp
; duplicate carry bit into all 8 AL bits
; similar to SALC instruction
.ret sbb al, al
ret
; set disk transfer address
; IN DS:DX dta ptr
setdta mov [cs:dta], dx
mov [cs:dta+2], ds
ret
; get disk transfer address
; OUT ES:BX dta ptr
getdta les bx, [cs:dta]
2021-01-23 18:32:53 +01:00
ret