collapseos/apps/zasm/directive.asm

64 lines
1.1 KiB
NASM
Raw Normal View History

2019-05-01 11:40:22 +10:00
; *** CONSTS ***
D_DB .equ 0x00
D_BAD .equ 0xff
; *** CODE ***
; 4 bytes per row, fill with zero
directiveNames:
.db ".DB", 0
2019-05-02 01:26:41 +10:00
; This is a list of handlers corresponding to indexes in directiveNames
directiveHandlers:
.dw handleDB
handleDB:
push de
push hl
call toWord
ld de, scratchpad
ld a, 8
call readWord
ld hl, scratchpad
call parseNumber
ld a, ixl
ld (direcData), a
ld a, 1
pop hl
pop de
ret
2019-05-01 11:40:22 +10:00
; Reads string in (HL) and returns the corresponding ID (D_*) in A. Sets Z if
; there's a match.
getDirectiveID:
push bc
push de
ld b, 1
ld c, 4
ld de, directiveNames
call findStringInList
pop de
pop bc
ret
2019-05-02 01:26:41 +10:00
; Parse directive specified in A (D_* const) with args in (HL) and act in
; an appropriate manner. If the directive results in writing data at its
; current location, that data is in (direcData) and A is the number of bytes
; in it.
2019-05-01 11:40:22 +10:00
parseDirective:
2019-05-02 01:26:41 +10:00
push de
; double A to have a proper offset in directiveHandlers
add a, a
ld de, directiveHandlers
call JUMP_ADDDE
ld ixh, d
ld ixl, e
pop de
jp (ix)
; *** Variables ***
direcData:
.fill 2