1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 16:28:05 +11:00

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.
This commit is contained in:
Virgil Dupras 2019-06-02 19:54:37 -04:00
parent 02954af570
commit 9a72f10221
6 changed files with 34 additions and 23 deletions

View File

@ -1,7 +1,8 @@
TARGET = os.bin
ZASM = ../../tools/zasm.sh
KERNEL = ../../kernel
.PHONY: all
all: $(TARGET)
$(TARGET): glue.asm
$(ZASM) < $< > $@
$(ZASM) $(KERNEL) < $< > $@

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 | \

View File

@ -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