Create basic MCB at boot

This commit is contained in:
Nero 2020-04-17 01:24:23 +02:00
parent 70a675442a
commit 6c165f40c0
2 changed files with 43 additions and 5 deletions

View File

@ -3,6 +3,7 @@
jmp 0x07C0:init jmp 0x07C0:init
%include "inc/bpb.asm" %include "inc/bpb.asm"
%include "kernel/mcb.asm"
banner: db "rdos", 0xA, 0xD, 0 banner: db "rdos", 0xA, 0xD, 0
@ -39,8 +40,6 @@ entry: push bp
mov ss, ax mov ss, ax
xor sp, sp xor sp, sp
int 3
; Jump back to userspace ; Jump back to userspace
ujump: cli ujump: cli
mov ax, es mov ax, es
@ -233,9 +232,8 @@ init: cli
call dnconv call dnconv
call select call select
int 3
mov ax, [cs:bpb+bpb_ss] call mcb_init
int 3
main: push cs main: push cs
pop ds pop ds

40
kernel/mcb.asm Normal file
View File

@ -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