diff --git a/tools/emul/Makefile b/tools/emul/Makefile index e1412b3..f92ed2a 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -1,27 +1,26 @@ TARGETS = shell/shell zasm/zasm runbin/runbin -KERNEL_HEADERS = shell/kernel.h zasm/kernel.h -USER_HEADERS = zasm/user.h CFSPACK = ../cfspack/cfspack KERNEL = ../../kernel APPS = ../../apps +ZASMBIN = zasm/zasm .PHONY: all all: $(TARGETS) shell/kernel.h: shell/shell_.asm -zasm/kernel.h: zasm/glue.asm -$(KERNEL_HEADERS): scas -o - -I $(KERNEL) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null -zasm/user.h: $(APPS)/zasm/glue.asm -$(USER_HEADERS): - scas -o - -I $(APPS) $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null +zasm/kernel.h: zasm/kernel.bin + ./bin2c.sh KERNEL < $< | tee $@ > /dev/null + +zasm/user.h: zasm/zasm.bin + ./bin2c.sh USERSPACE < $< | tee $@ > /dev/null zasm/includes.cfs: $(CFSPACK) rm -rf zasm/includes cp -r $(KERNEL) zasm/includes cp -r $(APPS)/zasm zasm/includes/zasm - find zasm/includes -name *.md -o -name *.example -delete + find zasm/includes -name *.md -o -name *.example -o -name glue.asm -delete find zasm/includes -type f -exec sed -i -e 's/;.*//g' {} \; cp user.h zasm/includes $(CFSPACK) zasm/includes > $@ @@ -31,7 +30,7 @@ zasm/includes.h: zasm/includes.cfs ./bin2c.sh FSDEV < $< | tee $@ > /dev/null shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK) -zasm/zasm: zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h +$(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h runbin/runbin: runbin/runbin.c libz80/libz80.o $(TARGETS): cc $< libz80/libz80.o -o $@ @@ -43,6 +42,11 @@ libz80/libz80.o: libz80/z80.c $(CFSPACK): make -C ../cfspack +.PHONY: updatebootstrap +updatebootstrap: $(ZASMBIN) + $(ZASMBIN) < zasm/glue.asm > zasm/kernel.bin + $(ZASMBIN) < $(APPS)/zasm/glue.asm > zasm/zasm.bin + .PHONY: clean clean: - rm -f $(TARGETS) $(KERNEL_HEADERS) $(USER_HEADERS) zasm/includes.* + rm -f $(TARGETS) zasm/{kernel,user}.h shell/kernel.h zasm/includes.* diff --git a/tools/emul/README.md b/tools/emul/README.md index 37cfe2a..77ec404 100644 --- a/tools/emul/README.md +++ b/tools/emul/README.md @@ -13,6 +13,18 @@ We don't try to emulate real hardware to ease the development of device drivers because so far, I don't see the advantage of emulation versus running code on the real thing. +## Bootstrapped binary + +The file `zasm/zasm.bin` is a compiled binary for `apps/zasm/glue.asm`. It is +used to bootstrap the assembling process so that no assembler other than zasm +is required to build Collapse OS. + +This binary is fed to libz80 to produce the `zasm/zasm` "modern" binary and +once you have that, you can recreate `zasm/zasm.bin`. + +This is why it's included as a binary in the repo, but yes, it's redundant with +the source code. + ## Usage First, make sure that the `libz80` git submodule is checked out. If not, run diff --git a/tools/emul/zasm/glue.asm b/tools/emul/zasm/glue.asm index d8d8a24..1b2c2c5 100644 --- a/tools/emul/zasm/glue.asm +++ b/tools/emul/zasm/glue.asm @@ -1,5 +1,6 @@ ; Glue code for the emulated environment .equ RAMSTART 0x4000 +.equ USER_CODE 0x4800 .equ STDIO_PORT 0x00 .equ STDIN_SEEK 0x01 .equ FS_DATA_PORT 0x02 @@ -39,7 +40,6 @@ jp fsTell .equ FS_RAMSTART BLOCKDEV_RAMEND .equ FS_HANDLE_COUNT 0 #include "fs.asm" -#include "user.h" init: di diff --git a/tools/emul/zasm/kernel.bin b/tools/emul/zasm/kernel.bin new file mode 100644 index 0000000..e2e5782 Binary files /dev/null and b/tools/emul/zasm/kernel.bin differ diff --git a/tools/emul/zasm/zasm.bin b/tools/emul/zasm/zasm.bin new file mode 100644 index 0000000..2ed59ed Binary files /dev/null and b/tools/emul/zasm/zasm.bin differ