From b0318f4891f20c13fc9278e87b2eb0cd459b8f34 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 17 May 2019 15:35:49 -0400 Subject: [PATCH] zasm: make instr unt write directly to ioPutC Couldn't get rid of instrUpcode though, too complicated. --- apps/zasm/instr.asm | 20 +++++++++++++++----- apps/zasm/main.asm | 18 +----------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index 171f987..3167c32 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.asm @@ -381,7 +381,7 @@ handleJPIXY: ld c, 2 ret .error: - xor c + ld c, 0 ret ; Handle the first argument of BIT. Sets Z if first argument is valid, unset it @@ -394,7 +394,7 @@ handleBIT: cp a ; ensure Z ret .error: - xor c + ld c, 0 call unsetZ ret @@ -733,8 +733,8 @@ processArg: ret ; Parse instruction specified in A (I_* const) with args in I/O and write -; resulting opcode(s) in (instrUpcode). Returns the number of bytes written in -; A. +; resulting opcode(s) in I/O. +; Sets Z on success. parseInstruction: push bc push hl @@ -775,9 +775,19 @@ parseInstruction: ; We have our matching instruction row. We're getting pretty near our ; goal here! call getUpcode + or a ; is zero? + jr z, .error + ld b, a ; save output byte count + ld hl, instrUpcode +.loopWrite: + ld a, (hl) + call ioPutC + inc hl + djnz .loopWrite + cp a ; ensure Z jr .end .error: - xor a + call unsetZ .end: pop de pop hl diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 26d08a9..5feaed7 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -150,23 +150,7 @@ parseLine: _parseInstr: ld a, c ; I_* - call parseInstruction - or a ; is zero? - jr z, .error - ld b, a ; save output byte count - ld hl, instrUpcode -.loopInstr: - ld a, (hl) - call ioPutC - inc hl - djnz .loopInstr - ; continue to success -.success: - xor a ; ensure Z - ret -.error: - call unsetZ - ret + jp parseInstruction _parseDirec: ld a, c ; D_*