From 346bcc3d3db301c3831e475864f349d59046bae4 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 29 Dec 2019 20:56:13 -0500 Subject: [PATCH] zasm: don't use lib/args This unit is being removed. --- apps/lib/util.asm | 25 +++++++++++++++++++++++ apps/zasm/glue.asm | 1 - apps/zasm/gluea.asm | 1 - apps/zasm/main.asm | 49 +++++++++++++++++++++++---------------------- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/apps/lib/util.asm b/apps/lib/util.asm index 58160f8..2bdea38 100644 --- a/apps/lib/util.asm +++ b/apps/lib/util.asm @@ -5,6 +5,31 @@ isWS: cp 0x09 ret +; Advance HL to next WS. +; Set Z if WS found, unset if end-of-string. +toWS: + ld a, (hl) + call isWS + ret z + or a + jp z, unsetZ + inc hl + jr toWS + +; Consume following whitespaces in HL until a non-WS is hit. +; Set Z if non-WS found, unset if end-of-string. +rdWS: + ld a, (hl) + call isWS + jr nz, .ok + or a + jp z, unsetZ + inc hl + jr rdWS +.ok: + cp a ; ensure Z + ret + ; Copy string from (HL) in (DE), that is, copy bytes until a null char is ; encountered. The null char is also copied. ; HL and DE point to the char right after the null char. diff --git a/apps/zasm/glue.asm b/apps/zasm/glue.asm index 291df8c..c86cb6e 100644 --- a/apps/zasm/glue.asm +++ b/apps/zasm/glue.asm @@ -68,7 +68,6 @@ jp zasmMain .inc "lib/util.asm" .inc "lib/ari.asm" .inc "lib/parse.asm" -.inc "lib/args.asm" .inc "zasm/util.asm" .equ IO_RAMSTART USER_RAMSTART .inc "zasm/io.asm" diff --git a/apps/zasm/gluea.asm b/apps/zasm/gluea.asm index e10073a..b4b06b9 100644 --- a/apps/zasm/gluea.asm +++ b/apps/zasm/gluea.asm @@ -25,7 +25,6 @@ jp zasmMain .inc "lib/util.asm" .inc "lib/ari.asm" .inc "lib/parse.asm" -.inc "lib/args.asm" .inc "zasm/util.asm" .equ IO_RAMSTART USER_RAMSTART .inc "zasm/io.asm" diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 8e0bd7a..02a1a72 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -23,34 +23,32 @@ ; HL is set to the last lineno to be read. ; Sets Z on success, unset on error. On error, A contains an error code (ERR_*) zasmMain: - ; Parse args. HL points to string already - ; We don't allocate memory just to hold this. Because this happens - ; before initialization, we don't really care where those args are - ; parsed. That's why we borrow zasm's RAMSTART for a little while. - ld de, .argspecs - ld ix, ZASM_RAMSTART - call parseArgs - jr z, .goodargs - ; bad args - ld hl, 0 - ld de, 0 - ld a, SHELL_ERR_BAD_ARGS - ret - -.goodargs: - ; HL now points to parsed args - ; Init I/O - ld a, (ZASM_RAMSTART) ; blkdev in ID + ; Parse args in (HL) + ; blkdev in + call parseHexPair ; --> A + jr c, .badargs ld de, IO_IN_BLK call blkSel - ld a, (ZASM_RAMSTART+1) ; blkdev out ID + inc hl ; char following last hex char + + ; blkdev in + call rdWS + jr nz, .badargs + call parseHexPair ; --> A + jr c, .badargs ld de, IO_OUT_BLK call blkSel + inc hl ; char following last hex char - ; Init .org - ; This is the 3rd argument, optional, will be zero if not given. + ; .org high byte + call rdWS + jr nz, .skipOrgSet ; no org argument + call parseHexPair ; --> A + jr c, .badargs + +.skipOrgSet: + ; Init .org with value of E ; Save in "@" too - ld a, (ZASM_RAMSTART+2) ld (ZASM_ORG+1), a ; high byte of .org ld (DIREC_LASTVAL+1), a xor a @@ -82,8 +80,11 @@ zasmMain: .end: jp ioLineNo ; --> HL, --> DE, returns -.argspecs: - .db 0b001, 0b001, 0b101 +.badargs: + ; bad args + ld a, SHELL_ERR_BAD_ARGS + ret + .sFirstPass: .db "First pass", 0 .sSecondPass: