From fa3b86a5c187bbac8e29582153c57804b6fcdd9a Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 19 May 2019 15:03:34 -0400 Subject: [PATCH] zasm now bootstraps itself without scas! --- tools/emul/Makefile | 24 ++++++++++++++---------- tools/emul/README.md | 12 ++++++++++++ tools/emul/zasm/glue.asm | 2 +- tools/emul/zasm/kernel.bin | Bin 0 -> 1064 bytes tools/emul/zasm/zasm.bin | Bin 0 -> 3976 bytes 5 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 tools/emul/zasm/kernel.bin create mode 100644 tools/emul/zasm/zasm.bin 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 0000000000000000000000000000000000000000..e2e5782c33c39e4ae20b78838c5a19bbe0026b13 GIT binary patch literal 1064 zcmZ`&O^6&t6n<6JJ9cJGW@cw}+X=GW8HvqAbdbO&UppHW^iFGL0Vdx+ZeQ2cvVTd@pc4A1j$8TnX;=w-DdtbfRU%mIe zDm4)58mUE6r%Bx;b%E3gQYT5BCACIso79k0fvKOkIx5tALR}H+D?#a}4OV%3q|<8I zuD)f%3y0@%Cb$@ot z7q#L&bAcQy7=O|3=-Y)X-w-z%`o^M8YvxN@J2pyh|FM8?0!H8no7ErO0~z@zC+)z{yomS@Y{ z3+5u}q+XOq=45PMmmtAgioRcCmwqr=I6b3qj`bB%l(1pY3n>**v6 z1S%`-Fa&zBUaq1+sBKR~nwrZn`F#X)1?Wk+S3e}xH*jHASQ4f~6dAa<64SddT~OL* zt5dJ;NZ1kB(M zVfcWe_u15&GNFsEN3vu~WK=&IfxvVA8|;e6tpET3 literal 0 HcmV?d00001 diff --git a/tools/emul/zasm/zasm.bin b/tools/emul/zasm/zasm.bin new file mode 100644 index 0000000000000000000000000000000000000000..2ed59ed19b52d38352fc5ef63277abf8cd0faba0 GIT binary patch literal 3976 zcmY*cdu&@*8UOrj5+|;m(Bv+Ovm4*6xpvm#nsyDD>dmp!`X+t^*G`<$t!(YKPU}oj zr8ORjT_G{{2cYo~AegFk(k4Ja29xSBq&x^gzAXnSV%`hxm>DiAkzrv=rwZkc-*MUk zS319Q&Ue1o`ObIlIcNF#3A3ft;n-BKsxz-H&i+c>nElr0XTJZ)y1G&|5Cy1q;gTmJ zT+h|Q2P#V-mJfBZW=iA%zZ4savPEih)D~7TRxNkViw!!-W~oj1aJ8c5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