From 7cdc288ef212739cf96136bc349073e91b313880 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 19 Jun 2019 11:42:39 -0400 Subject: [PATCH] zasm: print progress indicator while assembling --- apps/zasm/directive.asm | 10 ++++++++++ apps/zasm/glue.asm | 2 +- apps/zasm/io.asm | 11 +++++++++++ apps/zasm/main.asm | 8 ++++++++ tools/emul/zasm/glue.asm | 14 +++++++++++++- tools/emul/zasm/user.h | 1 + tools/emul/zasm/zasm.c | 5 +++++ tools/tests/zasm/test7.asm | 3 ++- 8 files changed, 51 insertions(+), 3 deletions(-) diff --git a/apps/zasm/directive.asm b/apps/zasm/directive.asm index 229839c..d80004d 100644 --- a/apps/zasm/directive.asm +++ b/apps/zasm/directive.asm @@ -80,6 +80,7 @@ handleDB: jr z, .stopStrLit ; be our closing quote. Stop. ; Normal character, output call ioPutC + jr nz, .ioError jr .stringLiteral handleDW: @@ -93,13 +94,18 @@ handleDW: push ix \ pop hl ld a, l call ioPutC + jr nz, .ioError ld a, h call ioPutC + jr nz, .ioError call readComma jr z, .loop cp a ; ensure Z pop hl ret +.ioError: + ld a, SHELL_ERR_IO_ERROR + jr .error .badfmt: ld a, ERR_BAD_FMT jr .error @@ -181,10 +187,14 @@ handleFIL: ld b, c .loop: call ioPutC + jr nz, .ioError djnz .loop cp a ; ensure Z pop bc ret +.ioError: + ld a, SHELL_ERR_IO_ERROR + jr .error .badfmt: ld a, ERR_BAD_FMT jr .error diff --git a/apps/zasm/glue.asm b/apps/zasm/glue.asm index aff11fd..dac44b5 100644 --- a/apps/zasm/glue.asm +++ b/apps/zasm/glue.asm @@ -18,7 +18,6 @@ ; during the first pass so forward references are not allowed. ; ; *** Requirements *** -; blockdev ; strncmp ; addDE ; addHL @@ -41,6 +40,7 @@ ; _blkPutC ; _blkSeek ; _blkTell +; printstr ; FS_HANDLE_SIZE ; BLOCKDEV_SIZE diff --git a/apps/zasm/io.asm b/apps/zasm/io.asm index c02d096..8ed4df8 100644 --- a/apps/zasm/io.asm +++ b/apps/zasm/io.asm @@ -223,6 +223,7 @@ ioInInclude: ; Open include file name specified in (HL). ; Sets Z on success, unset on error. ioOpenInclude: + call ioPrintLN call fsFindFN ret nz ld ix, IO_INCLUDE_HDL @@ -257,3 +258,13 @@ _ioIncGetC: _ioIncBlk: .dw _ioIncGetC, unsetZ +; call printstr followed by newline +ioPrintLN: + push hl + call printstr + ld hl, .sCRLF + call printstr + pop hl + ret +.sCRLF: + .db 0x0a, 0x0d, 0 diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index d98aba5..4b0facf 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -53,11 +53,15 @@ zasmMain: call symInit ; First pass + ld hl, .sFirstPass + call ioPrintLN ld a, 1 ld (ZASM_FIRST_PASS), a call zasmParseFile jr nz, .end ; Second pass + ld hl, .sSecondPass + call ioPrintLN xor a ld (ZASM_FIRST_PASS), a call zasmParseFile @@ -66,6 +70,10 @@ zasmMain: .argspecs: .db 0b001, 0b001, 0 +.sFirstPass: + .db "First pass", 0 +.sSecondPass: + .db "Second pass", 0 ; Sets Z according to whether we're in first pass. zasmIsFirstPass: diff --git a/tools/emul/zasm/glue.asm b/tools/emul/zasm/glue.asm index 97be16e..bc631d9 100644 --- a/tools/emul/zasm/glue.asm +++ b/tools/emul/zasm/glue.asm @@ -31,6 +31,7 @@ jp _blkGetC jp _blkPutC jp _blkSeek jp _blkTell +jp printstr #include "core.asm" #include "err.h" @@ -43,7 +44,10 @@ jp _blkTell .dw unsetZ, emulPutC .dw fsdevGetC, fsdevPutC -.equ FS_RAMSTART BLOCKDEV_RAMEND +.equ STDIO_RAMSTART BLOCKDEV_RAMEND +#include "stdio.asm" + +.equ FS_RAMSTART STDIO_RAMEND .equ FS_HANDLE_COUNT 0 #include "fs.asm" @@ -51,6 +55,9 @@ init: di ld hl, 0xffff ld sp, hl + ld hl, unsetZ + ld de, stderrPutC + call stdioInit ld a, 2 ; select fsdev ld de, BLOCKDEV_SEL call blkSel @@ -85,6 +92,11 @@ emulPutC: cp a ; ensure Z ret +stderrPutC: + out (STDERR_PORT), a + cp a ; ensure Z + ret + fsdevGetC: ld a, e out (FS_SEEK_PORT), a diff --git a/tools/emul/zasm/user.h b/tools/emul/zasm/user.h index a71a30d..0fedd48 100644 --- a/tools/emul/zasm/user.h +++ b/tools/emul/zasm/user.h @@ -26,3 +26,4 @@ .equ _blkPutC 0x3c .equ _blkSeek 0x3f .equ _blkTell 0x42 +.equ printstr 0x45 diff --git a/tools/emul/zasm/zasm.c b/tools/emul/zasm/zasm.c index b44ca24..f8ac9c8 100644 --- a/tools/emul/zasm/zasm.c +++ b/tools/emul/zasm/zasm.c @@ -40,6 +40,9 @@ // When defined, we dump memory instead of dumping expected stdout //#define MEMDUMP //#define DEBUG +// By default, we don't spit what zasm prints. Too noisy. Define VERBOSE if +// you want to spit this content to stderr. +//#define VERBOSE static Z80Context cpu; static uint8_t mem[0x10000]; @@ -132,7 +135,9 @@ static void io_write(int unused, uint16_t addr, uint8_t val) #endif } } else if (addr == STDERR_PORT) { +#ifdef VERBOSE fputc(val, stderr); +#endif } else { fprintf(stderr, "Out of bounds I/O write: %d / %d (0x%x)\n", addr, val, val); } diff --git a/tools/tests/zasm/test7.asm b/tools/tests/zasm/test7.asm index 240d147..7a01cac 100644 --- a/tools/tests/zasm/test7.asm +++ b/tools/tests/zasm/test7.asm @@ -1,6 +1,6 @@ .equ USER_CODE 0x4800 .equ USER_RAMSTART 0x5800 -.equ FS_HANDLE_SIZE 8 +.equ FS_HANDLE_SIZE 6 .equ BLOCKDEV_SIZE 8 ; *** JUMP TABLE *** @@ -26,6 +26,7 @@ .equ _blkPutC 0x3c .equ _blkSeek 0x3f .equ _blkTell 0x42 +.equ printstr 0x45 #include "err.h" #include "zasm/const.asm"