find root directory for fcb opening

This commit is contained in:
Nero 2019-11-04 13:10:50 +00:00
parent b164c79f42
commit 8b30a6c5e2

View File

@ -6,10 +6,10 @@ ORG BDOS
DISKBUF: EQU (BDOS-0x200) ; deblocking DISKBUF: EQU (BDOS-0x200) ; deblocking
DISKBPB: EQU (DISKBUF-21) ; BPB of the current driv DISKBPB: EQU (DISKBUF-21) ; BPB of the current driv
DISKDRV: EQU (DISKBPB-1) ; BYTE denoting drive of current fcb DISKDRV: EQU (DISKBPB-1) ; BYTE denoting drive of current fcb (1=A, ...)
STACK: EQU (DISKDRV & 0xFFFE) ; even address, grows down STACK: EQU (DISKDRV & 0xFFFE) ; even address, grows down
DEFDRV: EQU 4 ; default drive when opening a FCB DEFDRV: EQU 4 ; default drive when opening a FCB (1=A, ...)
SYSCALL: SYSCALL:
TEST CL, CL TEST CL, CL
@ -32,12 +32,9 @@ SETUP:
MOV CX, DISKBUF MOV CX, DISKBUF
CALL SETDMA CALL SETDMA
MOV CL, 0x00 SUB SP, 0x20
CALL LOADBPB MOV BX, SP
CALL FCBOPEN
MOV AX, [DISKBPB]
INT3
CLI CLI
HALT: HALT:
@ -135,6 +132,8 @@ SYSCALL2:
CMP CL, 14 CMP CL, 14
JE SETDEFDSK JE SETDEFDSK
CMP CL, 15 CMP CL, 15
JE FCBOPEN
RET:
RET RET
DISKRST: DISKRST:
@ -145,9 +144,63 @@ SETDEFDSK:
MOV BYTE [DEFDRV], DL MOV BYTE [DEFDRV], DL
RET RET
; IN CL drive num FCBOPEN:
LOADBPB: MOV CL, BYTE [BX]
TEST CL, CL
JNZ NODEFDRV
MOV CL, BYTE [DEFDRV]
MOV BYTE [BX], CL
NODEFDRV:
CALL LOADBPB
CALL FATSIZE
ADD DX, WORD [DISKBPB+BPB_RSC]
CALL SETLSEC
CALL READ
MOV AX, [DISKBUF]
INT3
; TODO: search for file in rootdir
; TODO: init cluster number
RET
; Set logical sector number
; IN DX sector number
SETLSEC:
PUSH AX
PUSH CX PUSH CX
PUSH DX
XOR AX, AX
XCHG AX, DX
DIV WORD [DISKBPB+BPB_SPT]
MOV CX, AX
CALL SETTRK
MOV CX, DX
INC CX
CALL SETSEC
POP DX
POP CX
POP AX
RET
; OUT DX number of sectors by all FATs
FATSIZE:
PUSH AX
MOV DL, BYTE [DISKBPB+BPB_FN]
MOV AL, BYTE [DISKBPB+BPB_SF]
MUL DL
XCHG AX, DX
POP AX
RET
; IN CL drive num, 1=A, 2=B, 3=C
LOADBPB:
CMP BYTE [DISKDRV], CL
JE RET
PUSH CX
DEC CL
CALL SELDSK CALL SELDSK
; first track ; first track
MOV CX, 0 MOV CX, 0
@ -158,8 +211,13 @@ LOADBPB:
; into default diskbuf ; into default diskbuf
MOV CX, DISKBUF MOV CX, DISKBUF
CALL SETDMA CALL SETDMA
POP CX
CALL READ CALL READ
JC DISKRST
; copy BPB ; copy BPB
PUSH CX
PUSH SI PUSH SI
PUSH DI PUSH DI
MOV CX, 21 MOV CX, 21
@ -168,10 +226,8 @@ LOADBPB:
REP MOVSB REP MOVSB
POP DI POP DI
POP SI POP SI
; store drive number
POP CX POP CX
; store drive number
MOV BYTE [DISKDRV], CL MOV BYTE [DISKDRV], CL
RET RET
FCBOPEN:
RET