From 8b30a6c5e204f57608219f13d468cc535a2e6a35 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Mon, 4 Nov 2019 13:10:50 +0000 Subject: [PATCH] find root directory for fcb opening --- bdos/8086.asm | 84 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/bdos/8086.asm b/bdos/8086.asm index 3d9b483..4787bee 100644 --- a/bdos/8086.asm +++ b/bdos/8086.asm @@ -6,10 +6,10 @@ ORG BDOS DISKBUF: EQU (BDOS-0x200) ; deblocking 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 -DEFDRV: EQU 4 ; default drive when opening a FCB +DEFDRV: EQU 4 ; default drive when opening a FCB (1=A, ...) SYSCALL: TEST CL, CL @@ -32,12 +32,9 @@ SETUP: MOV CX, DISKBUF CALL SETDMA - MOV CL, 0x00 - CALL LOADBPB - - MOV AX, [DISKBPB] - - INT3 + SUB SP, 0x20 + MOV BX, SP + CALL FCBOPEN CLI HALT: @@ -135,6 +132,8 @@ SYSCALL2: CMP CL, 14 JE SETDEFDSK CMP CL, 15 + JE FCBOPEN +RET: RET DISKRST: @@ -145,9 +144,63 @@ SETDEFDSK: MOV BYTE [DEFDRV], DL RET -; IN CL drive num -LOADBPB: +FCBOPEN: + 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 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 ; first track MOV CX, 0 @@ -158,8 +211,13 @@ LOADBPB: ; into default diskbuf MOV CX, DISKBUF CALL SETDMA + POP CX + CALL READ + JC DISKRST + ; copy BPB + PUSH CX PUSH SI PUSH DI MOV CX, 21 @@ -168,10 +226,8 @@ LOADBPB: REP MOVSB POP DI POP SI - ; store drive number POP CX + + ; store drive number MOV BYTE [DISKDRV], CL RET - -FCBOPEN: - RET