diff --git a/boot/kernel.asm b/boot/kernel.asm index 323fc40..9691c4a 100644 --- a/boot/kernel.asm +++ b/boot/kernel.asm @@ -3,6 +3,7 @@ jmp 0x07C0:init %include "inc/bpb.asm" + %include "kernel/mcb.asm" banner: db "rdos", 0xA, 0xD, 0 @@ -39,8 +40,6 @@ entry: push bp mov ss, ax xor sp, sp - int 3 - ; Jump back to userspace ujump: cli mov ax, es @@ -233,9 +232,8 @@ init: cli call dnconv call select - int 3 - mov ax, [cs:bpb+bpb_ss] - int 3 + + call mcb_init main: push cs pop ds diff --git a/kernel/mcb.asm b/kernel/mcb.asm new file mode 100644 index 0000000..08a8601 --- /dev/null +++ b/kernel/mcb.asm @@ -0,0 +1,40 @@ + ; First MCB block is always at 00540 +mcb_first: + mov ax, 0x54 + mov ds, ax + ret + +mcb_init: + call mcb_first + mov dx, ds + inc dx + xor si, si + int 0x12 + mov cl, 6 + shl ax, cl + sub ax, dx + mov byte [si+0], 'Z' + mov word [si+1], 0 + mov word [si+3], ax + mov dx, cs + call mcb_find + int 3 + ret + + ; IN dx segment we look for + ; OUT ds segment where mcb starts +mcb_find: + call mcb_first + xor si, si +.loop: stc + adc ax, [si+3] + cmp dx, ax + jc .found + cmp byte [si+0], 'Z' + jz .fail + mov ds, ax + jmp .loop +.fail: stc + ret +.found: clc + ret