From 175e1328e796ec27d39456a8648aa936925cc36f Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 30 Apr 2019 13:45:31 -0400 Subject: [PATCH] zasm: consolidate * Build emulated zasm statically * Improve comments in zasm.asm * Fix build * Use unsetZ from core --- apps/zasm/emul/Makefile | 11 ++++++----- apps/zasm/emul/glue.asm | 1 + apps/zasm/emul/user.inc | 1 + apps/zasm/zasm.asm | 32 +++++++++++++------------------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/apps/zasm/emul/Makefile b/apps/zasm/emul/Makefile index c1745a8..b1145d2 100644 --- a/apps/zasm/emul/Makefile +++ b/apps/zasm/emul/Makefile @@ -1,11 +1,12 @@ -zasm: zasm.c libz80/libz80.so kernel.h zasm.h - cc $< -l z80 -L./libz80 -Wl,-rpath ./libz80 -o $@ +zasm: zasm.c libz80/libz80.o kernel.h zasm.h + cc $< libz80/libz80.o -o $@ -libz80/libz80.so: libz80/Makefile - make -C libz80 +libz80/libz80.o: libz80/z80.c + make -C libz80/codegen opcodes + gcc -Wall -ansi -g -c -o libz80/libz80.o libz80/z80.c kernel.h: glue.asm - scas -o - -I ../../../parts $< | ./bin2c.sh KERNEL | tee $@ > /dev/null + scas -o - -I ../../../parts/z80 $< | ./bin2c.sh KERNEL | tee $@ > /dev/null zasm.h: ../zasm.asm ../tok.asm scas -o - -I.. $< | ./bin2c.sh ZASM | tee $@ > /dev/null diff --git a/apps/zasm/emul/glue.asm b/apps/zasm/emul/glue.asm index edaa75e..f612f20 100644 --- a/apps/zasm/emul/glue.asm +++ b/apps/zasm/emul/glue.asm @@ -8,6 +8,7 @@ jr init ; 2 bytes jp strncmp jp addDE jp upcase +jp unsetZ init: di diff --git a/apps/zasm/emul/user.inc b/apps/zasm/emul/user.inc index 18df114..c8e77d5 100644 --- a/apps/zasm/emul/user.inc +++ b/apps/zasm/emul/user.inc @@ -6,3 +6,4 @@ USER_CODE .equ RAMSTART JUMP_STRNCMP .equ 0x02 JUMP_ADDDE .equ 0x05 JUMP_UPCASE .equ 0x08 +JUMP_UNSETZ .equ 0x0b diff --git a/apps/zasm/zasm.asm b/apps/zasm/zasm.asm index 1db1fc0..0a7089c 100644 --- a/apps/zasm/zasm.asm +++ b/apps/zasm/zasm.asm @@ -20,15 +20,6 @@ ret #include "tok.asm" -; TODO: call from core -unsetZ: - push bc - ld b, a - inc b - cp b - pop bc - ret - ; run RLA the number of times specified in B rlaX: ; first, see if B == 0 to see if we need to bail out @@ -93,7 +84,7 @@ enterParens: ret ; we're good! .doNotEnter: pop hl - call unsetZ + call JUMP_UNSETZ ret ; Checks whether A is 'N' or 'M' @@ -167,7 +158,7 @@ parseNumber: jr .loop .error: - call unsetZ + call JUMP_UNSETZ .end: pop bc pop de @@ -312,7 +303,7 @@ isGroupId: cp a ret .notgroup: - call unsetZ + call JUMP_UNSETZ ret ; Find argspec A in group id H. @@ -382,7 +373,7 @@ findInGroup: jr .end .notfound: pop bc ; from the push bc in .find - call unsetZ + call JUMP_UNSETZ .end: pop hl pop bc @@ -403,7 +394,7 @@ matchArg: cp 0 jr nz, .checkIfNumber ; not a zero, we can continue ; zero, stop here - call unsetZ + call JUMP_UNSETZ ret .checkIfNumber: ; not an exact match, let's check for numerical constants. @@ -502,7 +493,7 @@ handleBIT: ret .error: xor c - call unsetZ + call JUMP_UNSETZ ret handleBITHL: @@ -792,7 +783,7 @@ processArg: cp a ; ensure Z is set ret .error: - call unsetZ + call JUMP_UNSETZ ret ; Parse line at (HL) and write resulting opcode(s) in curUpcode. Returns the @@ -910,8 +901,8 @@ argGrpCC: argGrpABCDEHL: .db "BCDEHL_A" ; 0xb -; This is a list of primary instructions (single upcode) that lead to a -; constant (no group code to insert). Format: +; This is a list of all supported instructions. Each row represent a combination +; of instr/argspecs (which means more than one row per instr). Format: ; ; 4 bytes for the name (fill with zero) ; 1 byte for arg constant @@ -919,9 +910,12 @@ argGrpABCDEHL: ; 1 byte displacement for group arguments + flags ; 2 bytes for upcode (2nd byte is zero if instr is one byte) ; +; An "arg constant" is a char corresponding to either a row in argspecTbl or +; a group index in argGrpTbl (values < 0x10 are considered group indexes). +; ; The displacement bit is split in 2 nibbles: lower nibble is the displacement ; value, upper nibble is for flags: - +; ; Bit 7: indicates that the numerical argument is of the 'e' type and has to be ; decreased by 2 (djnz, jr). ; Bit 6: it indicates that the group argument's value is to be placed on the