From b3014ef8e47e1620dc3c608088c0a9424a8ebaa6 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Wed, 16 Oct 2019 21:09:31 +0000 Subject: [PATCH] Meh --- kernel/fcb.asm | 38 ++++++++++---------------------------- kernel/main.asm | 4 ++-- lib/fdc.asm | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 30 deletions(-) create mode 100644 lib/fdc.asm diff --git a/kernel/fcb.asm b/kernel/fcb.asm index a299e51..85d0e60 100644 --- a/kernel/fcb.asm +++ b/kernel/fcb.asm @@ -13,7 +13,7 @@ fcb_cs: equ 15 ; byte cluster size: 0=128, 1=256, 2=512, ... fcb_co: equ 16 ; word start sector for theoretical cluster 0 ; Read/Write pointer (6 bytes) -fcb_left: equ 18 ; word number of bytes left to read from diskbuf +fcb_left: equ 18 ; word number of bytes left to read in current sector fcb_off: equ 20 ; dword offset in disk (not in file) ; Link to directory item (4 bytes) @@ -23,6 +23,7 @@ fcb_end: equ 32 fcb_open_rootdir: mov dl, 0x01 + or dl, 0x80 mov [bx], dl dec dl @@ -30,6 +31,7 @@ fcb_open_rootdir: ; Default 2 heads, 9 sectors mov word [bx+fcb_spt], 0x0209 xor ax, ax + xor dx, dx lea di, [bx+fcb_ss] ; Sector & Cluster size 128 bytes mov cx, (fcb_end - fcb_ss) @@ -39,9 +41,7 @@ fcb_open_rootdir: call drive_read ; copy sector size - mov ax, [diskbuf + 0x0B] - ; ... save as number of valid bytes in diskbuf - mov WORD [bx+fcb_left], ax + mov ax, [diskbuf + fdc_ss] call log2 sub ax, 7 ; ... save as sector size @@ -55,35 +55,17 @@ fcb_open_rootdir: mov byte [bx+fcb_cs], al ; copy sectors per track - mov al, [diskbuf + 0x18] + mov al, [diskbuf + fdc_spt] mov byte [bx+fcb_spt], al ; copy number of heads/sides mov al, [diskbuf + 0x1A] mov byte [bx+fcb_nos], al - ret + xor dx, dx + mov ax, [diskbuf + fdc_sf] + mul byte [diskbuf + fdc_fn] + add ax, [diskbuf + fdc_rsc] + int3 -fcb_get_sector_mask: - push cx - xor ax, ax - not ax - mov cl, [bx+fcb_ss] - add cl, 7 - shl ax, cl - pop cx - ret - -fcb_getc: - push bx - call fcb_get_sector_mask - not ax - and ax, [bx+fcb_off] - xchg ax, bx - add bx, diskbuf - mov al, [bx] - pop bx - add word [bx+fcb_off], 1 - adc word [bx+fcb_off+2], 0 - dec word [bx+fcb_left] ret diff --git a/kernel/main.asm b/kernel/main.asm index 92da89f..793b237 100644 --- a/kernel/main.asm +++ b/kernel/main.asm @@ -22,8 +22,7 @@ init: mov dx, banner call print_string - mov si, init_program - call exec + call exec_chain cli .halt: @@ -50,6 +49,7 @@ cpm_syscall: %include "char.asm" %include "exec.asm" +%include "fdc.asm" %include "fcb.asm" %include "fcbparse.asm" %include "drive.asm" diff --git a/lib/fdc.asm b/lib/fdc.asm new file mode 100644 index 0000000..dbb21e6 --- /dev/null +++ b/lib/fdc.asm @@ -0,0 +1,14 @@ +; FDC Descriptor / BIOS parameter block +fdc_ss: equ 0x0B ; WORD sector size +fdc_sc: equ 0x0D ; BYTE sectors per cluster +fdc_rsc: equ 0x0E ; WORD reserved sectors +fdc_fn: equ 0x10 ; BYTE FAT tables +fdc_rde: equ 0x11 ; WORD root directory entries +fdc_ts: equ 0x13 ; WORD total sector count + ; 0 if >65535, use lrgts then +fdc_mi: equ 0x15 ; BYTE media descriptor byte +fdc_sf: equ 0x16 ; WORD sectors per FAT +fdc_spt: equ 0x18 ; WORD sectors per track +fdc_nos: equ 0x1A ; WORD sides/heads +fdc_po: equ 0x1C ; DWORD partition offset +fdc_lrgts: equ 0x20 ; DWORD large sector count