Add mechanism for additional files on floppy

This commit is contained in:
Nero 2019-09-15 19:03:08 +00:00
parent fc0dd47d48
commit 956df75dae
2 changed files with 26 additions and 4 deletions

View File

@ -2,6 +2,9 @@ FD_CYLINDERS = 40
FD_HEADS = 2 FD_HEADS = 2
FD_SECTORS = 9 FD_SECTORS = 9
PROGRAMS = $(patsubst %.asm,%.com,$(wildcard programs/*.asm))
DISTFILES = kernel.com $(PROGRAMS)
QEMU_ARCH = $(shell uname -m) QEMU_ARCH = $(shell uname -m)
QEMU = qemu-system-$(QEMU_ARCH) QEMU = qemu-system-$(QEMU_ARCH)
@ -31,14 +34,16 @@ debug.rom: debug/*.asm lib/*.inc
floppy.bs: boot/fatvbr.asm floppy.bs: boot/fatvbr.asm
nasm -s -DCMDLINE='"KERNEL.COM"' -o $@ $< nasm -s -DCMDLINE='"KERNEL.COM"' -o $@ $<
fdimage.img: floppy.bs kernel.com programs/%.com: programs/%.asm
nasm -s -I lib -o $@ $<
fdimage.img: floppy.bs $(DISTFILES)
dd if=/dev/zero bs=512 count=$$(( $(FD_CYLINDERS) * $(FD_HEADS) * $(FD_SECTORS) )) of=$@ dd if=/dev/zero bs=512 count=$$(( $(FD_CYLINDERS) * $(FD_HEADS) * $(FD_SECTORS) )) of=$@
mformat -i $@ -t $(FD_CYLINDERS) -h $(FD_HEADS) -n $(FD_SECTORS) -B floppy.bs :: mformat -i $@ -t $(FD_CYLINDERS) -h $(FD_HEADS) -n $(FD_SECTORS) -B floppy.bs ::
mcopy -i $@ kernel.com ::kernel.com mcopy -i $@ $(DISTFILES) ::
mattrib -i $@ +s ::kernel.com
clean: clean:
rm -f *.com *.bin *.rom *.img *.log *.bs *.lst rm -f *.com *.bin *.rom *.img *.log *.bs *.lst programs/*.com
qemu-floppy: fdimage.img $(DEBUGROM) qemu-floppy: fdimage.img $(DEBUGROM)
$(QEMU) $(QEMU_ARGS) -boot c -fda fdimage.img $(QEMU) $(QEMU_ARGS) -boot c -fda fdimage.img

17
programs/hello.asm Normal file
View File

@ -0,0 +1,17 @@
org 0x0100
main:
mov si, hello
.loop:
lodsb
test al, al
jz .ret
mov dl, al
mov ah, 0x02
int 0x21
jmp .loop
.ret:
ret
hello:
db "Hello!", 0