From 157ac03e25bf6b64251c1b160fb1470b23c3324a Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 17 May 2019 20:47:43 -0400 Subject: [PATCH] zasm: can now assemble zasm/util.asm! --- apps/zasm/instr.asm | 4 ++-- apps/zasm/util.asm | 2 +- parts/z80/core.asm | 2 +- tools/emul/Makefile | 6 ++++-- tools/tests/zasm/runtests.sh | 5 +++-- tools/tests/zasm/test7.asm | 8 ++++++++ 6 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 tools/tests/zasm/test7.asm diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index 9df25b4..4e16873 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.asm @@ -1087,8 +1087,8 @@ instrTBl: .db I_SBC, 'A', 'l', 0, 0x9e , 0 ; SBC A, (HL) .db I_SBC, 'A', 0xb, 0, 0b10011000 , 0 ; SBC A, r .db I_SCF, 0, 0, 0, 0x37 , 0 ; SCF - .db I_SUB, 'A', 'l', 0, 0x96 , 0 ; SUB A, (HL) - .db I_SUB, 'A', 0xb, 0, 0b10010000 , 0 ; SUB A, r + .db I_SUB, 'l', 0, 0, 0x96 , 0 ; SUB (HL) + .db I_SUB, 0xb, 0, 0, 0b10010000 , 0 ; SUB r .db I_SUB, 'n', 0, 0, 0xd6 , 0 ; SUB n .db I_XOR, 'l', 0, 0, 0xae , 0 ; XOR (HL) .db I_XOR, 0xb, 0, 0, 0b10101000 , 0 ; XOR r diff --git a/apps/zasm/util.asm b/apps/zasm/util.asm index c76d45c..5324b3b 100644 --- a/apps/zasm/util.asm +++ b/apps/zasm/util.asm @@ -29,7 +29,7 @@ subDEFromHL: sub e ld l, a ld a, h - sbc d + sbc a, d ld h, a pop af ret diff --git a/parts/z80/core.asm b/parts/z80/core.asm index e71f3bc..b0d4001 100644 --- a/parts/z80/core.asm +++ b/parts/z80/core.asm @@ -128,7 +128,7 @@ findchar: .match: ; We ran 0xff-B loops. That's the result that goes in A. ld a, 0xff - sub a, b + sub b cp a ; ensure Z .end: pop bc diff --git a/tools/emul/Makefile b/tools/emul/Makefile index d936fbe..b8c0ce4 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -14,8 +14,10 @@ $(KERNEL_HEADERS): zasm/user.h: zasm/user.asm scas -o - -I ../../apps $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null -zasm/includes.cfs: ../../parts/z80 $(CFSPACK) - cp -rf $< zasm/includes +zasm/includes.cfs: $(CFSPACK) + rm -rf zasm/includes + cp -r ../../parts/z80 zasm/includes + cp -r ../../apps/zasm zasm/includes/zasm find zasm/includes -name *.md -delete find zasm/includes -type f -exec sed -i -e 's/;.*//g' {} \; $(CFSPACK) zasm/includes > $@ diff --git a/tools/tests/zasm/runtests.sh b/tools/tests/zasm/runtests.sh index ede830e..144c1ca 100755 --- a/tools/tests/zasm/runtests.sh +++ b/tools/tests/zasm/runtests.sh @@ -5,11 +5,12 @@ set -e TMPFILE=$(mktemp) SCAS=scas PARTS=../../../parts/z80 +APPS=../../../apps ZASM=../../emul/zasm/zasm -ASMFILE=../../../apps/zasm/instr.asm +ASMFILE=${APPS}/zasm/instr.asm cmpas() { - EXPECTED=$($SCAS -I ${PARTS} -o - "$1" | xxd) + EXPECTED=$($SCAS -I ${PARTS} -I ${APPS} -o - "$1" | xxd) ACTUAL=$(cat $1 | $ZASM | xxd) if [ "$ACTUAL" == "$EXPECTED" ]; then echo ok diff --git a/tools/tests/zasm/test7.asm b/tools/tests/zasm/test7.asm new file mode 100644 index 0000000..1f6ed12 --- /dev/null +++ b/tools/tests/zasm/test7.asm @@ -0,0 +1,8 @@ +.equ RAMSTART 0x4000 +.equ ZASM_FIRST_PASS RAMSTART +.equ ZASM_LOCAL_PASS ZASM_FIRST_PASS+1 +.equ ZASM_CTX_PC ZASM_LOCAL_PASS+1 +.equ ZASM_RAMEND ZASM_CTX_PC+2 + +#include "core.asm" +#include "zasm/util.asm"