mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:58:09 +11:00
zasm: creep in the notion of directive
This commit is contained in:
parent
8241298c8f
commit
1ffe05dd09
@ -415,14 +415,14 @@ matchArg:
|
||||
dec hl
|
||||
ret
|
||||
|
||||
; Compare primary row at (DE) with ID at (tokInstr). Sets Z flag if there's a
|
||||
; Compare primary row at (DE) with ID at (tokInstr+1). Sets Z flag if there's a
|
||||
; match, reset if not.
|
||||
matchPrimaryRow:
|
||||
push hl
|
||||
push ix
|
||||
ld ixh, d
|
||||
ld ixl, e
|
||||
ld a, (tokInstr)
|
||||
ld a, (tokInstr+1)
|
||||
cp (ix)
|
||||
jr nz, .end
|
||||
; name matches, let's see the rest
|
||||
@ -774,9 +774,10 @@ processArg:
|
||||
parseTokens:
|
||||
push hl
|
||||
push de
|
||||
ld a, (tokInstr)
|
||||
cp TOK_BAD
|
||||
jr z, .error ; for now, we treat blank lines as errors
|
||||
ld a, (tokInstr) ; TOK_*
|
||||
cp TOK_INSTR
|
||||
jr nz, .error ; Not an instruction, error
|
||||
ld a, (tokInstr+1) ; I_*
|
||||
ld hl, tokArg1
|
||||
ld de, curArg1
|
||||
call processArg
|
||||
|
@ -54,6 +54,7 @@ parseLine:
|
||||
#include "util.asm"
|
||||
#include "tok.asm"
|
||||
#include "instr.asm"
|
||||
#include "directive.asm"
|
||||
|
||||
; *** Variables ***
|
||||
|
||||
|
@ -7,13 +7,14 @@
|
||||
|
||||
; *** Consts ***
|
||||
TOK_INSTR .equ 0x01
|
||||
TOK_DIRECTIVE .equ 0x02
|
||||
TOK_BAD .equ 0xff
|
||||
|
||||
; *** Code ***
|
||||
; 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.
|
||||
; Parse line in (HL) and read the next token in (DE). The token is written on
|
||||
; two bytes. The first byte is a token type (TOK_* constants) and the second
|
||||
; byte is an ID specific to that token type.
|
||||
; If no token matches, TOK_BAD is written to (DE)
|
||||
tokenize:
|
||||
xor a
|
||||
ld (de), a
|
||||
@ -22,11 +23,27 @@ tokenize:
|
||||
call readWord
|
||||
ex hl, de
|
||||
call getInstID
|
||||
ex hl, de
|
||||
jr z, .match
|
||||
jr z, .instr
|
||||
call getDirectiveID
|
||||
jr z, .direc
|
||||
; no match
|
||||
ex hl, de ; swap it back
|
||||
ld a, TOK_BAD
|
||||
.match:
|
||||
ld (de), a
|
||||
ret
|
||||
.instr:
|
||||
ex af, af'
|
||||
ld a, TOK_INSTR
|
||||
jr .end
|
||||
.direc:
|
||||
ex af, af'
|
||||
ld a, TOK_DIRECTIVE
|
||||
jr .end
|
||||
.end:
|
||||
ex hl, de ; swap it back
|
||||
ld (de), a
|
||||
ex af, af'
|
||||
inc de
|
||||
ld (de), a
|
||||
ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user