Implement MCB splitting

This commit is contained in:
Nero 2020-04-17 23:33:42 +02:00
parent 6c165f40c0
commit 6d38a313c7
2 changed files with 31 additions and 1 deletions

View File

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

View File

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