Skip to content

Commit f8549fe

Browse files
committed
Fix bug with DIM AT not working sometimes
1 parent 5b6065b commit f8549fe

6 files changed

Lines changed: 100 additions & 3 deletions

File tree

src/api/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def is_number(*p):
268268
containing NUMBER or numeric CONSTANTS
269269
"""
270270
try:
271-
return all(i.token == 'NUMBER' or (i.token == 'ID' and i.class_ == CLASS.const) for i in p)
271+
return all(i.token == 'NUMBER' or is_const(i) for i in p)
272272
except Exception:
273273
pass
274274

src/libzxbc/zxbparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def p_var_decl_at(p):
689689
else:
690690
entry.addr = tmp
691691

692-
elif not is_number(p[5]):
692+
elif not is_static(p[5]):
693693
src.api.errmsg.syntax_error_address_must_be_constant(p.lineno(4))
694694
return
695695
else:
@@ -777,7 +777,7 @@ def p_arr_decl_attr(p):
777777
elif expr.operand.token not in ('VAR', 'LABEL'):
778778
error(p.lineno(3), 'Only addresses of identifiers are allowed')
779779
return
780-
elif not is_number(expr):
780+
elif not is_static(expr):
781781
src.api.errmsg.syntax_error_address_must_be_constant(p.lineno(3))
782782
return
783783

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
jp __MAIN_PROGRAM__
14+
ZXBASIC_USER_DATA:
15+
; Defines USER DATA Length in bytes
16+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
17+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
18+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
19+
_tile.__DATA__ EQU 16768
20+
_tile:
21+
DEFW __LABEL0
22+
_tile.__DATA__.__PTR__:
23+
DEFW 16768
24+
__LABEL0:
25+
DEFW 0000h
26+
DEFB 02h
27+
ZXBASIC_USER_DATA_END:
28+
__MAIN_PROGRAM__:
29+
ld hl, 0
30+
ld b, h
31+
ld c, l
32+
__END_PROGRAM:
33+
di
34+
ld hl, (__CALL_BACK__)
35+
ld sp, hl
36+
exx
37+
pop hl
38+
exx
39+
pop iy
40+
pop ix
41+
ei
42+
ret
43+
__CALL_BACK__:
44+
DEFW 0
45+
;; --- end of user code ---
46+
END
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
const tileStart as uinteger = $4000+384
3+
4+
dim tile(0 to 255) as uinteger at tileStart
5+
6+

tests/functional/dim_at_label8.asm

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
jp __MAIN_PROGRAM__
14+
ZXBASIC_USER_DATA:
15+
; Defines USER DATA Length in bytes
16+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
17+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
18+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
19+
_p EQU 16768
20+
ZXBASIC_USER_DATA_END:
21+
__MAIN_PROGRAM__:
22+
ld hl, 0
23+
ld b, h
24+
ld c, l
25+
__END_PROGRAM:
26+
di
27+
ld hl, (__CALL_BACK__)
28+
ld sp, hl
29+
exx
30+
pop hl
31+
exx
32+
pop iy
33+
pop ix
34+
ei
35+
ret
36+
__CALL_BACK__:
37+
DEFW 0
38+
;; --- end of user code ---
39+
END

tests/functional/dim_at_label8.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
const tileStart as uinteger = $4000+384
3+
4+
dim p as Uinteger at tileStart
5+
6+

0 commit comments

Comments
 (0)