From 956df75dae9798af61d98449eb6f46890610cb80 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Sun, 15 Sep 2019 19:03:08 +0000 Subject: [PATCH] Add mechanism for additional files on floppy --- Makefile | 13 +++++++++---- programs/hello.asm | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 programs/hello.asm diff --git a/Makefile b/Makefile index a35d6b5..58de885 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ FD_CYLINDERS = 40 FD_HEADS = 2 FD_SECTORS = 9 +PROGRAMS = $(patsubst %.asm,%.com,$(wildcard programs/*.asm)) +DISTFILES = kernel.com $(PROGRAMS) + QEMU_ARCH = $(shell uname -m) QEMU = qemu-system-$(QEMU_ARCH) @@ -31,14 +34,16 @@ debug.rom: debug/*.asm lib/*.inc floppy.bs: boot/fatvbr.asm 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=$@ mformat -i $@ -t $(FD_CYLINDERS) -h $(FD_HEADS) -n $(FD_SECTORS) -B floppy.bs :: - mcopy -i $@ kernel.com ::kernel.com - mattrib -i $@ +s ::kernel.com + mcopy -i $@ $(DISTFILES) :: 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) $(QEMU_ARGS) -boot c -fda fdimage.img diff --git a/programs/hello.asm b/programs/hello.asm new file mode 100644 index 0000000..71ed1b5 --- /dev/null +++ b/programs/hello.asm @@ -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