mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 20:08:05 +11:00
zasm: add support for the ".dw" directive
This commit is contained in:
parent
dde5161fc1
commit
6811d98618
@ -1,17 +1,20 @@
|
||||
; *** CONSTS ***
|
||||
|
||||
D_DB .equ 0x00
|
||||
D_BAD .equ 0xff
|
||||
.equ D_DB 0x00
|
||||
.equ D_DW 0x01
|
||||
.equ D_BAD 0xff
|
||||
|
||||
; *** CODE ***
|
||||
|
||||
; 4 bytes per row, fill with zero
|
||||
directiveNames:
|
||||
.db ".DB", 0
|
||||
.db ".DW", 0
|
||||
|
||||
; This is a list of handlers corresponding to indexes in directiveNames
|
||||
directiveHandlers:
|
||||
.dw handleDB
|
||||
.dw handleDW
|
||||
|
||||
handleDB:
|
||||
push de
|
||||
@ -29,13 +32,30 @@ handleDB:
|
||||
pop de
|
||||
ret
|
||||
|
||||
handleDW:
|
||||
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, ixh
|
||||
ld (direcData+1), a
|
||||
ld a, 2
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
|
||||
; 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 b, D_DW+1 ; D_DW is last
|
||||
ld c, 4
|
||||
ld de, directiveNames
|
||||
call findStringInList
|
||||
@ -53,6 +73,7 @@ parseDirective:
|
||||
add a, a
|
||||
ld de, directiveHandlers
|
||||
call JUMP_ADDDE
|
||||
call JUMP_INTODE
|
||||
ld ixh, d
|
||||
ld ixl, e
|
||||
pop de
|
||||
|
@ -9,6 +9,7 @@ jp strncmp
|
||||
jp addDE
|
||||
jp upcase
|
||||
jp unsetZ
|
||||
jp intoDE
|
||||
|
||||
init:
|
||||
di
|
||||
|
@ -7,3 +7,4 @@ JUMP_STRNCMP .equ 0x02
|
||||
JUMP_ADDDE .equ 0x05
|
||||
JUMP_UPCASE .equ 0x08
|
||||
JUMP_UNSETZ .equ 0x0b
|
||||
JUMP_INTODE .equ 0x0e
|
||||
|
@ -3,3 +3,5 @@
|
||||
inc a ; comment
|
||||
; comment
|
||||
.db 42
|
||||
.dw 42
|
||||
.dw 3742
|
||||
|
Loading…
Reference in New Issue
Block a user