zasm: move token variables from tok.asm into main.asm

This commit is contained in:
Virgil Dupras 2019-04-30 17:04:42 -04:00
parent a7635cb1ea
commit 79b5c701f6
2 changed files with 27 additions and 28 deletions

View File

@ -24,9 +24,16 @@ main:
; to where we should write the next upcode. ; to where we should write the next upcode.
parseLine: parseLine:
push bc push bc
call gotoNextNotBlankLine call gotoNextNotBlankLine
push de
ld de, tokInstr
call tokenize call tokenize
jr nz, .error ld de, tokArg1
call tokenizeInstrArg
ld de, tokArg2
call tokenizeInstrArg
pop de
call parseTokens call parseTokens
or a ; is zero? or a ; is zero?
jr z, .error jr z, .error
@ -47,3 +54,13 @@ parseLine:
#include "util.asm" #include "util.asm"
#include "tok.asm" #include "tok.asm"
#include "instr.asm" #include "instr.asm"
; *** Variables ***
tokInstr:
.fill 5
tokArg1:
.fill 9
tokArg2:
.fill 9

View File

@ -6,33 +6,24 @@
; JUMP_UPCASE ; JUMP_UPCASE
; *** Code *** ; *** Code ***
; Parse line in (HL) and place each element in tokInstr, tokArg1, tokArg2. Those ; Parse line in (HL) and read the next token in (DE). For now, it only supports
; values are null-terminated and empty if not present. All letters are ; instructions. Arguments must be tokenized with the appropriate specialized
; routine. Values are null-terminated and empty if not present. All letters are
; uppercased. ; 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: tokenize:
push de
xor a xor a
ld (tokInstr), a ld (de), a
ld (tokArg1), a
ld (tokArg2), a
ld de, tokInstr
call toWord call toWord
ld a, 4 ld a, 4
call readWord call readWord
ret
tokenizeInstrArg:
xor a
ld (de), a
call toWord call toWord
jr nz, .end
ld de, tokArg1
ld a, 8 ld a, 8
call readWord call readWord
call toWord
jr nz, .end
ld de, tokArg2
call readWord
.end:
xor a ; ensure Z
pop de
ret ret
; Sets Z is A is ';', CR, LF, or null. ; Sets Z is A is ';', CR, LF, or null.
@ -156,12 +147,3 @@ gotoNextNotBlankLine:
ret nz ret nz
jr gotoNextNotBlankLine jr gotoNextNotBlankLine
; *** Variables ***
tokInstr:
.fill 5
tokArg1:
.fill 9
tokArg2:
.fill 9