Drop MCBs as mean to manage memory
This commit is contained in:
parent
f7d3d5c62f
commit
4a92c4bc1e
2
Makefile
2
Makefile
@ -48,8 +48,6 @@ 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 $@ $<
|
||||
|
@ -1,9 +1,8 @@
|
||||
cpu 8086
|
||||
org 0
|
||||
jmp 0x07C0:init
|
||||
org 0x500
|
||||
jmp init
|
||||
|
||||
%include "inc/bpb.asm"
|
||||
%include "kernel/mcb.asm"
|
||||
|
||||
banner: db "rdos", 0xA, 0xD, 0
|
||||
|
||||
@ -223,21 +222,7 @@ ldbpb: push ds
|
||||
pop ds
|
||||
ret
|
||||
|
||||
init: cli
|
||||
mov ax, cs
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
xor sp, sp
|
||||
|
||||
call dnconv
|
||||
call select
|
||||
|
||||
call mcb_init
|
||||
|
||||
main: push cs
|
||||
pop ds
|
||||
mov si, banner
|
||||
main: mov si, banner
|
||||
mov ah, 0x0e
|
||||
xor bx, bx
|
||||
loop: lodsb
|
||||
@ -248,3 +233,19 @@ loop: lodsb
|
||||
end: hlt
|
||||
jmp end
|
||||
|
||||
init: cli
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
xor sp, sp
|
||||
|
||||
mov si, 0x7C00
|
||||
mov di, $$
|
||||
mov cx, (init-$$)
|
||||
rep movsb
|
||||
|
||||
call dnconv
|
||||
call select
|
||||
|
||||
jmp 0:main
|
||||
|
@ -1,70 +0,0 @@
|
||||
; 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_split
|
||||
mov word [si+1], 8
|
||||
ret
|
||||
|
||||
; split mcb block into two
|
||||
; IN dx segment of second block
|
||||
mcb_split:
|
||||
call mcb_find
|
||||
dec dx
|
||||
push 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
|
||||
stc
|
||||
sbb dx, ax
|
||||
pop ax
|
||||
mov ds, 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
|
||||
; 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
|
Loading…
Reference in New Issue
Block a user