collapseos/apps/zasm/tok.asm

36 lines
687 B
NASM
Raw Normal View History

2019-04-21 09:25:52 -04:00
; *** Requirements ***
; JUMP_UPCASE
2019-04-30 21:13:37 -04:00
; *** Consts ***
TOK_INSTR .equ 0x01
2019-04-30 21:27:44 -04:00
TOK_DIRECTIVE .equ 0x02
2019-04-30 21:13:37 -04:00
TOK_BAD .equ 0xff
2019-04-21 09:25:52 -04:00
; *** Code ***
2019-04-30 22:27:11 -04:00
; Parse line in (HL) and read the next token in BC. The token is written on
; two bytes (B and C). B is a token type (TOK_* constants) and C is an ID
; specific to that token type.
; Advance HL to after the read word.
; If no token matches, TOK_BAD is written to B
2019-04-21 09:25:52 -04:00
tokenize:
call toWord
2019-04-21 09:25:52 -04:00
call readWord
2019-04-30 22:27:11 -04:00
push hl ; Save advanced HL for later
ld hl, scratchpad
call getInstID
2019-04-30 21:27:44 -04:00
jr z, .instr
call getDirectiveID
jr z, .direc
2019-04-30 21:13:37 -04:00
; no match
2019-04-30 22:27:11 -04:00
ld b, TOK_BAD
jr .end
2019-04-30 21:27:44 -04:00
.instr:
2019-04-30 22:27:11 -04:00
ld b, TOK_INSTR
2019-04-30 21:27:44 -04:00
jr .end
.direc:
2019-04-30 22:27:11 -04:00
ld b, TOK_DIRECTIVE
2019-04-30 21:27:44 -04:00
.end:
2019-04-30 22:27:11 -04:00
ld c, a
pop hl
ret