Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def is_number(*p):
containing NUMBER or numeric CONSTANTS
"""
try:
return all(i.token == 'NUMBER' or (i.token == 'ID' and i.class_ == CLASS.const) for i in p)
return all(i.token == 'NUMBER' or is_const(i) for i in p)
except Exception:
pass

Expand Down
4 changes: 2 additions & 2 deletions src/libzxbc/zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def p_var_decl_at(p):
else:
entry.addr = tmp

elif not is_number(p[5]):
elif not is_static(p[5]):
src.api.errmsg.syntax_error_address_must_be_constant(p.lineno(4))
return
else:
Expand Down Expand Up @@ -777,7 +777,7 @@ def p_arr_decl_attr(p):
elif expr.operand.token not in ('VAR', 'LABEL'):
error(p.lineno(3), 'Only addresses of identifiers are allowed')
return
elif not is_number(expr):
elif not is_static(expr):
src.api.errmsg.syntax_error_address_must_be_constant(p.lineno(3))
return

Expand Down
46 changes: 46 additions & 0 deletions tests/functional/dim_arr_at_label2.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
org 32768
__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld hl, 0
add hl, sp
ld (__CALL_BACK__), hl
ei
jp __MAIN_PROGRAM__
ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
_tile.__DATA__ EQU 16768
_tile:
DEFW __LABEL0
_tile.__DATA__.__PTR__:
DEFW 16768
__LABEL0:
DEFW 0000h
DEFB 02h
ZXBASIC_USER_DATA_END:
__MAIN_PROGRAM__:
ld hl, 0
ld b, h
ld c, l
__END_PROGRAM:
di
ld hl, (__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
__CALL_BACK__:
DEFW 0
;; --- end of user code ---
END
6 changes: 6 additions & 0 deletions tests/functional/dim_arr_at_label2.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const tileStart as uinteger = $4000+384

dim tile(0 to 255) as uinteger at tileStart


39 changes: 39 additions & 0 deletions tests/functional/dim_at_label8.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
org 32768
__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld hl, 0
add hl, sp
ld (__CALL_BACK__), hl
ei
jp __MAIN_PROGRAM__
ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
_p EQU 16768
ZXBASIC_USER_DATA_END:
__MAIN_PROGRAM__:
ld hl, 0
ld b, h
ld c, l
__END_PROGRAM:
di
ld hl, (__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
__CALL_BACK__:
DEFW 0
;; --- end of user code ---
END
6 changes: 6 additions & 0 deletions tests/functional/dim_at_label8.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const tileStart as uinteger = $4000+384

dim p as Uinteger at tileStart