瀏覽代碼

zasm: creep in the notion of directive

pull/10/head
Virgil Dupras 5 年之前
父節點
當前提交
1ffe05dd09
共有 3 個文件被更改,包括 31 次插入12 次删除
  1. +6
    -5
      apps/zasm/instr.asm
  2. +1
    -0
      apps/zasm/main.asm
  3. +24
    -7
      apps/zasm/tok.asm

+ 6
- 5
apps/zasm/instr.asm 查看文件

@@ -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


+ 1
- 0
apps/zasm/main.asm 查看文件

@@ -54,6 +54,7 @@ parseLine:
#include "util.asm"
#include "tok.asm"
#include "instr.asm"
#include "directive.asm"

; *** Variables ***



+ 24
- 7
apps/zasm/tok.asm 查看文件

@@ -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…
取消
儲存