1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 18:28:05 +11:00
collapseos/apps/zasm/tok.asm

36 lines
687 B
NASM
Raw Normal View History

2019-04-21 23:25:52 +10:00
; *** Requirements ***
; JUMP_UPCASE
2019-05-01 11:13:37 +10:00
; *** Consts ***
TOK_INSTR .equ 0x01
2019-05-01 11:27:44 +10:00
TOK_DIRECTIVE .equ 0x02
2019-05-01 11:13:37 +10:00
TOK_BAD .equ 0xff
2019-04-21 23:25:52 +10:00
; *** Code ***
2019-05-01 12:27:11 +10: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 23:25:52 +10:00
tokenize:
call toWord
2019-04-21 23:25:52 +10:00
call readWord
2019-05-01 12:27:11 +10:00
push hl ; Save advanced HL for later
ld hl, scratchpad
call getInstID
2019-05-01 11:27:44 +10:00
jr z, .instr
call getDirectiveID
jr z, .direc
2019-05-01 11:13:37 +10:00
; no match
2019-05-01 12:27:11 +10:00
ld b, TOK_BAD
jr .end
2019-05-01 11:27:44 +10:00
.instr:
2019-05-01 12:27:11 +10:00
ld b, TOK_INSTR
2019-05-01 11:27:44 +10:00
jr .end
.direc:
2019-05-01 12:27:11 +10:00
ld b, TOK_DIRECTIVE
2019-05-01 11:27:44 +10:00
.end:
2019-05-01 12:27:11 +10:00
ld c, a
pop hl
ret