From 9a72f10221c2739f304226b1e0faeb83459a4fcb Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 2 Jun 2019 19:54:37 -0400 Subject: [PATCH] zasm: includes CFS is now built on-the-fly by zasm.sh This makes for a much more usable zasm linux binary that doesn't have to be rebuilt every time apps or kernel change. --- recipes/rc2014/Makefile | 3 ++- recipes/rc2014/sdcard/Makefile | 3 ++- tools/emul/Makefile | 22 ++++++++-------------- tools/tests/unit/runtests.sh | 10 +++++++--- tools/tests/zasm/runtests.sh | 8 +++++--- tools/zasm.sh | 11 ++++++++++- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/recipes/rc2014/Makefile b/recipes/rc2014/Makefile index d51a00f..c9a9feb 100644 --- a/recipes/rc2014/Makefile +++ b/recipes/rc2014/Makefile @@ -1,7 +1,8 @@ TARGET = os.bin ZASM = ../../tools/zasm.sh +KERNEL = ../../kernel .PHONY: all all: $(TARGET) $(TARGET): glue.asm - $(ZASM) < $< > $@ + $(ZASM) $(KERNEL) < $< > $@ diff --git a/recipes/rc2014/sdcard/Makefile b/recipes/rc2014/sdcard/Makefile index 906742d..00db76c 100644 --- a/recipes/rc2014/sdcard/Makefile +++ b/recipes/rc2014/sdcard/Makefile @@ -1,6 +1,7 @@ TARGETS = os.bin cfsin/helo TOOLS = ../../../tools ZASM = $(TOOLS)/zasm.sh +KERNEL = ../../../kernel CFSPACK = $(TOOLS)/cfspack/cfspack .PHONY: all @@ -8,7 +9,7 @@ all: $(TARGETS) sdcard.cfs os.bin: glue.asm cfsin/helo: helo.asm $(TARGETS): - $(ZASM) < $< > $@ + $(ZASM) $(KERNEL) < $< > $@ $(CFSPACK): make -C $(TOOLS)/cfspack diff --git a/tools/emul/Makefile b/tools/emul/Makefile index 80354bb..a92776c 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -1,16 +1,15 @@ -TARGETS = shell/shell zasm/zasm runbin/runbin CFSPACK = ../cfspack/cfspack +TARGETS = shell/shell zasm/zasm runbin/runbin KERNEL = ../../kernel APPS = ../../apps ZASMBIN = zasm/zasm -INCCFS = zasm/includes.cfs -SRCPATTERN = *.+(asm|h) +ZASMSH = ../zasm.sh .PHONY: all all: $(TARGETS) -shell/kernel.h: shell/shell_.asm $(ZASMBIN) $(INCCFS) - $(ZASMBIN) $(INCCFS) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null +shell/kernel.h: shell/shell_.asm $(ZASMBIN) + $(ZASMSH) $(KERNEL) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null zasm/kernel.h: zasm/kernel.bin ./bin2c.sh KERNEL < $< | tee $@ > /dev/null @@ -18,13 +17,8 @@ zasm/kernel.h: zasm/kernel.bin zasm/user.h: zasm/zasm.bin ./bin2c.sh USERSPACE < $< | tee $@ > /dev/null -$(INCCFS): $(CFSPACK) - $(CFSPACK) $(KERNEL) "$(SRCPATTERN)" > $@ - $(CFSPACK) $(APPS) "$(SRCPATTERN)" >> $@ - $(CFSPACK) user.h >> $@ - -shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK) -$(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h +shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h +$(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h $(CFSPACK) runbin/runbin: runbin/runbin.c libz80/libz80.o $(TARGETS): $(CC) $< libz80/libz80.o -o $@ @@ -38,8 +32,8 @@ $(CFSPACK): .PHONY: updatebootstrap updatebootstrap: $(ZASMBIN) $(INCCFS) - $(ZASMBIN) $(INCCFS) < zasm/glue.asm > zasm/kernel.bin - $(ZASMBIN) $(INCCFS) < $(APPS)/zasm/glue.asm > zasm/zasm.bin + $(ZASMSH) $(KERNEL) < zasm/glue.asm > zasm/kernel.bin + $(ZASMSH) $(KERNEL) $(APPS) user.h < $(APPS)/zasm/glue.asm > zasm/zasm.bin # Sometimes, when developing zasm, stuff get messed up and it's hard to unmess # because zasm's brake-up ends up in its bootstrap bins. Sure, we can revert diff --git a/tools/tests/unit/runtests.sh b/tools/tests/unit/runtests.sh index 8dec42e..e7fdb58 100755 --- a/tools/tests/unit/runtests.sh +++ b/tools/tests/unit/runtests.sh @@ -3,12 +3,16 @@ set -e set -o pipefail -ZASM=../../zasm.sh -RUNBIN=../../emul/runbin/runbin +BASE=../../.. +TOOLS=../.. +ZASM="${TOOLS}/zasm.sh" +RUNBIN="${TOOLS}/emul/runbin/runbin" +KERNEL="${BASE}/kernel" +APPS="${BASE}/apps" for fn in *.asm; do echo "Running test ${fn}" - if ! ${ZASM} < ${fn} | ${RUNBIN}; then + if ! ${ZASM} "${KERNEL}" "${APPS}" < ${fn} | ${RUNBIN}; then echo "failed with code ${PIPESTATUS[1]}" exit 1 fi diff --git a/tools/tests/zasm/runtests.sh b/tools/tests/zasm/runtests.sh index eca3014..03d3925 100755 --- a/tools/tests/zasm/runtests.sh +++ b/tools/tests/zasm/runtests.sh @@ -10,8 +10,10 @@ ZASM=../../zasm.sh ASMFILE=${APPS}/zasm/instr.asm cmpas() { - EXPECTED=$($SCAS -I ${KERNEL} -I ${APPS} -o - "$1" | xxd) - ACTUAL=$(cat $1 | $ZASM | xxd) + FN=$1 + shift 1 + EXPECTED=$($SCAS -I ${KERNEL} -I ${APPS} -o - "${FN}" | xxd) + ACTUAL=$(cat ${FN} | $ZASM "$@" | xxd) if [ "$ACTUAL" == "$EXPECTED" ]; then echo ok else @@ -25,7 +27,7 @@ cmpas() { for fn in test*.asm; do echo "Comparing ${fn}" - cmpas $fn + cmpas $fn "${KERNEL}" "${APPS}" done ./geninstrs.py $ASMFILE | \ diff --git a/tools/zasm.sh b/tools/zasm.sh index 8d835f5..584ea2c0 100755 --- a/tools/zasm.sh +++ b/tools/zasm.sh @@ -3,5 +3,14 @@ # wrapper around ./emul/zasm/zasm that prepares includes CFS prior to call DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" ZASMBIN="${DIR}/emul/zasm/zasm" -INCCFS="${DIR}/emul/zasm/includes.cfs" +CFSPACK="${DIR}/cfspack/cfspack" +INCCFS=$(mktemp) + +for p in "$@"; do + "${CFSPACK}" "${p}" "*.+(asm|h)" >> "${INCCFS}" +done + "${ZASMBIN}" "${INCCFS}" +RES=$? +rm "${INCCFS}" +exit $RES