From 79b5c701f60d68bf62dc3fa1c03fcdadfbb6dd1b Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 30 Apr 2019 17:04:42 -0400 Subject: [PATCH] zasm: move token variables from tok.asm into main.asm --- apps/zasm/main.asm | 19 ++++++++++++++++++- apps/zasm/tok.asm | 36 +++++++++--------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 8e4641e..081eab0 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -24,9 +24,16 @@ main: ; to where we should write the next upcode. parseLine: push bc + call gotoNextNotBlankLine + push de + ld de, tokInstr call tokenize - jr nz, .error + ld de, tokArg1 + call tokenizeInstrArg + ld de, tokArg2 + call tokenizeInstrArg + pop de call parseTokens or a ; is zero? jr z, .error @@ -47,3 +54,13 @@ parseLine: #include "util.asm" #include "tok.asm" #include "instr.asm" + +; *** Variables *** + +tokInstr: + .fill 5 +tokArg1: + .fill 9 +tokArg2: + .fill 9 + diff --git a/apps/zasm/tok.asm b/apps/zasm/tok.asm index 43646fb..49f4881 100644 --- a/apps/zasm/tok.asm +++ b/apps/zasm/tok.asm @@ -6,33 +6,24 @@ ; JUMP_UPCASE ; *** Code *** -; Parse line in (HL) and place each element in tokInstr, tokArg1, tokArg2. Those -; values are null-terminated and empty if not present. All letters are +; Parse line in (HL) and read the next token in (DE). For now, it only supports +; instructions. Arguments must be tokenized with the appropriate specialized +; routine. Values are null-terminated and empty if not present. All letters are ; uppercased. -; Sets Z on success, unsets it on error. Blank line is not an error. -; (as of now, we don't have any error condition. We always succeed) tokenize: - push de xor a - ld (tokInstr), a - ld (tokArg1), a - ld (tokArg2), a - ld de, tokInstr + ld (de), a call toWord ld a, 4 call readWord + ret + +tokenizeInstrArg: + xor a + ld (de), a call toWord - jr nz, .end - ld de, tokArg1 ld a, 8 call readWord - call toWord - jr nz, .end - ld de, tokArg2 - call readWord -.end: - xor a ; ensure Z - pop de ret ; Sets Z is A is ';', CR, LF, or null. @@ -156,12 +147,3 @@ gotoNextNotBlankLine: ret nz jr gotoNextNotBlankLine -; *** Variables *** - -tokInstr: - .fill 5 -tokArg1: - .fill 9 -tokArg2: - .fill 9 -