From 6d38a313c7dd960770af3703c554bf9795ed356b Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Fri, 17 Apr 2020 23:33:42 +0200 Subject: [PATCH] Implement MCB splitting --- Makefile | 2 ++ kernel/mcb.asm | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d564f76..467cf36 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,8 @@ vga11.com: cp437.bin %.bs: boot/%.asm $(NASM) $(NASM_ARGS) -o $@ $< +kernel.bs: kernel/*.asm + # Special case: variations of FAT vbr fat1.bs: boot/fat.asm $(NASM) $(NASM_ARGS) -DFAT12 -DCHS -o $@ $< diff --git a/kernel/mcb.asm b/kernel/mcb.asm index 08a8601..3d089a8 100644 --- a/kernel/mcb.asm +++ b/kernel/mcb.asm @@ -17,8 +17,36 @@ mcb_init: mov word [si+1], 0 mov word [si+3], ax mov dx, cs + call mcb_split + mov word [si+1], 8 + ret + + ; split mcb block into two + ; IN dx segment of second block +mcb_split: call mcb_find - int 3 + dec dx + ; Calculate size of first block + ; dx = dx - ds - 1 + stc + mov ax, ds + sbb dx, ax + ; + push dx + ; swap old size with new size + xchg dx, [si+3] + ; if current mcb is last, its not anymore + mov cl, 'M' + xchg cl, byte [si+0] + ; advance DS to begin of first block + pop ax + mov ds, ax + stc + sbb dx, ax + ; write MCB data + mov byte [si+0], cl + mov word [si+1], 0 + mov word [si+3], dx ret ; IN dx segment we look for