Skip to content

Commit ff4902e

Browse files
committed
Put DATAs in .DATA namespace
1 parent 4aada48 commit ff4902e

22 files changed

Lines changed: 392 additions & 207 deletions

src/api/global_.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@
117117
# ----------------------------------------------------------------------
118118
SIZE_TYPE = None
119119

120+
# ----------------------------------------------------------------------
121+
# DATA Labels namespace
122+
# ----------------------------------------------------------------------
123+
DATAS_NAMESPACE = '.DATA'
124+
120125
# ----------------------------------------------------------------------
121126
# Data Type used for string chars index. Must be an integral
122127
# ----------------------------------------------------------------------

src/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def current_data_label() -> str:
110110
""" Returns a data label to which all labels must point to, until
111111
a new DATA line is declared
112112
"""
113-
return '__DATA__{0}'.format(len(global_.DATAS))
113+
return f'{global_.DATAS_NAMESPACE}.__DATA__{len(global_.DATAS)}'
114114

115115

116116
def flatten_list(x: Iterable[Any], iterables=(list, )) -> List[Any]:

src/arch/zx48k/library-asm/read_restore.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ read_restart:
6868
jr nz, cont
6969
;; Signals out of data
7070

71-
ld hl, __DATA__0
71+
ld hl, .DATA.__DATA__0
7272
ld (__DATA_ADDR), hl
7373
jr read_restart ; Start again
7474
cont:
@@ -339,7 +339,7 @@ __09_decode_float:
339339
ret
340340

341341
__DATA_ADDR: ;; Stores current DATA ptr
342-
dw __DATA__0
342+
dw .DATA.__DATA__0
343343
ENDP
344344

345345
#undef _str

tests/functional/arrbase1.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ read_restart:
10551055
or a ; 0 => OUT of data
10561056
jr nz, cont
10571057
;; Signals out of data
1058-
ld hl, __DATA__0
1058+
ld hl, .DATA.__DATA__0
10591059
ld (__DATA_ADDR), hl
10601060
jr read_restart ; Start again
10611061
cont:
@@ -1306,7 +1306,7 @@ __09_decode_float:
13061306
ld h, a ; returns A in H; sets A free
13071307
ret
13081308
__DATA_ADDR: ;; Stores current DATA ptr
1309-
dw __DATA__0
1309+
dw .DATA.__DATA__0
13101310
ENDP
13111311
pop namespace
13121312
#line 48 "arrbase1.bas"

tests/functional/data1.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ core.__MAIN_PROGRAM__:
3333
call core.__STOREF
3434
__LABEL__1010:
3535
__LABEL__4500:
36-
ld hl, __DATA__1
36+
ld hl, .DATA.__DATA__1
3737
call core.__RESTORE
3838
__LABEL__5000:
3939
ld hl, 0
@@ -50,10 +50,10 @@ core.__END_PROGRAM:
5050
pop ix
5151
ei
5252
ret
53-
__DATA__0:
53+
.DATA.__DATA__0:
5454
DEFB 3
5555
DEFB 0
56-
__DATA__1:
56+
.DATA.__DATA__1:
5757
__DATA__END:
5858
DEFB 00h
5959
;; --- end of user code ---
@@ -892,7 +892,7 @@ read_restart:
892892
or a ; 0 => OUT of data
893893
jr nz, cont
894894
;; Signals out of data
895-
ld hl, __DATA__0
895+
ld hl, .DATA.__DATA__0
896896
ld (__DATA_ADDR), hl
897897
jr read_restart ; Start again
898898
cont:
@@ -1143,7 +1143,7 @@ __09_decode_float:
11431143
ld h, a ; returns A in H; sets A free
11441144
ret
11451145
__DATA_ADDR: ;; Stores current DATA ptr
1146-
dw __DATA__0
1146+
dw .DATA.__DATA__0
11471147
ENDP
11481148
pop namespace
11491149
#line 32 "data1.bas"

tests/functional/memcpytest.asm

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ core.__END_PROGRAM:
7676
ret
7777
_MemMove:
7878
#line 32 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
79+
push namespace core
7980
exx
8081
pop hl
8182
exx
@@ -85,11 +86,13 @@ _MemMove:
8586
push hl
8687
exx
8788
jp __MEMCPY
88-
#line 49 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
89+
pop namespace
90+
#line 51 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
8991
_MemMove__leave:
9092
ret
9193
_MemCopy:
92-
#line 66 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
94+
#line 68 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
95+
push namespace core
9396
exx
9497
pop hl
9598
exx
@@ -99,11 +102,13 @@ _MemCopy:
99102
push hl
100103
exx
101104
ldir
102-
#line 83 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
105+
pop namespace
106+
#line 87 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
103107
_MemCopy__leave:
104108
ret
105109
_MemSet:
106-
#line 97 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
110+
#line 101 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
111+
push namespace core
107112
pop de
108113
pop af
109114
pop bc
@@ -117,7 +122,8 @@ _MemSet:
117122
ld e,l
118123
inc de
119124
ldir
120-
#line 116 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
125+
pop namespace
126+
#line 122 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
121127
_MemSet__leave:
122128
ret
123129
__LABEL5:
@@ -193,7 +199,7 @@ __CLS_SCR:
193199
; to get the start of the screen
194200
ENDP
195201
pop namespace
196-
#line 128 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
202+
#line 134 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
197203
#line 1 "/zxbasic/src/arch/zx48k/library-asm/memcopy.asm"
198204
; ----------------------------------------------------------------
199205
; This file is released under the MIT License
@@ -235,7 +241,7 @@ __MEMCPY2:
235241
ret
236242
ENDP
237243
pop namespace
238-
#line 129 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
244+
#line 135 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
239245
#line 1 "/zxbasic/src/arch/zx48k/library-asm/pause.asm"
240246
; The PAUSE statement (Calling the ROM)
241247
push namespace core
@@ -244,7 +250,7 @@ __PAUSE:
244250
ld c, l
245251
jp 1F3Dh ; PAUSE_1
246252
pop namespace
247-
#line 130 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
253+
#line 136 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
248254
#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm"
249255
#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm"
250256
; vim:ts=4:sw=4:et:
@@ -1457,5 +1463,5 @@ __PRINT_STR:
14571463
jp __PRINT_STR_LOOP
14581464
ENDP
14591465
pop namespace
1460-
#line 131 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
1466+
#line 137 "/zxbasic/src/arch/zx48k/library/memcopy.bas"
14611467
END

tests/functional/opt3_data2.asm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ ___DATA__FUNCPTR__5:
115115
ld a, (_a.__DATA__ + 4)
116116
___DATA__FUNCPTR__5__leave:
117117
ret
118-
__DATA__0:
118+
.DATA.__DATA__0:
119119
DEFB 3
120120
DEFB 2
121121
DEFB 3
@@ -126,7 +126,7 @@ __DATA__0:
126126
DEFB 7
127127
DEFB 3
128128
DEFB 0
129-
__DATA__1:
129+
.DATA.__DATA__1:
130130
DEFB 83h
131131
DEFW ___DATA__FUNCPTR__1
132132
DEFB 83h
@@ -2210,7 +2210,7 @@ read_restart:
22102210
or a ; 0 => OUT of data
22112211
jr nz, cont
22122212
;; Signals out of data
2213-
ld hl, __DATA__0
2213+
ld hl, .DATA.__DATA__0
22142214
ld (__DATA_ADDR), hl
22152215
jr read_restart ; Start again
22162216
cont:
@@ -2461,7 +2461,7 @@ __09_decode_float:
24612461
ld h, a ; returns A in H; sets A free
24622462
ret
24632463
__DATA_ADDR: ;; Stores current DATA ptr
2464-
dw __DATA__0
2464+
dw .DATA.__DATA__0
24652465
ENDP
24662466
pop namespace
24672467
#line 100 "opt3_data2.bas"

tests/functional/read.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ _a:
2727
DEFB 00, 00, 00, 00, 00
2828
core.ZXBASIC_USER_DATA_END:
2929
core.__MAIN_PROGRAM__:
30-
ld hl, __DATA__0
30+
ld hl, .DATA.__DATA__0
3131
call core.__RESTORE
3232
ld a, 9
3333
call core.__READ
@@ -54,14 +54,14 @@ ___DATA__FUNCPTR__0:
5454
call core.__LOADSTR
5555
___DATA__FUNCPTR__0__leave:
5656
ret
57-
__DATA__0:
57+
.DATA.__DATA__0:
5858
DEFB 3
5959
DEFB 20
6060
DEFB 3
6161
DEFB 20
6262
DEFB 3
6363
DEFB 30
64-
__DATA__1:
64+
.DATA.__DATA__1:
6565
DEFB 81h
6666
DEFW ___DATA__FUNCPTR__0
6767
__DATA__END:
@@ -908,7 +908,7 @@ read_restart:
908908
or a ; 0 => OUT of data
909909
jr nz, cont
910910
;; Signals out of data
911-
ld hl, __DATA__0
911+
ld hl, .DATA.__DATA__0
912912
ld (__DATA_ADDR), hl
913913
jr read_restart ; Start again
914914
cont:
@@ -1159,7 +1159,7 @@ __09_decode_float:
11591159
ld h, a ; returns A in H; sets A free
11601160
ret
11611161
__DATA_ADDR: ;; Stores current DATA ptr
1162-
dw __DATA__0
1162+
dw .DATA.__DATA__0
11631163
ENDP
11641164
pop namespace
11651165
#line 49 "read.bas"

tests/functional/read10.asm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _v:
3232
DEFB 00h
3333
core.ZXBASIC_USER_DATA_END:
3434
core.__MAIN_PROGRAM__:
35-
ld hl, __DATA__0
35+
ld hl, .DATA.__DATA__0
3636
call core.__RESTORE
3737
call _p
3838
ld hl, 0
@@ -133,7 +133,7 @@ ___DATA__FUNCPTR__2:
133133
call core.__MULF
134134
___DATA__FUNCPTR__2__leave:
135135
ret
136-
__DATA__0:
136+
.DATA.__DATA__0:
137137
DEFB 3
138138
DEFB 10
139139
DEFB 89h
@@ -2132,7 +2132,7 @@ read_restart:
21322132
or a ; 0 => OUT of data
21332133
jr nz, cont
21342134
;; Signals out of data
2135-
ld hl, __DATA__0
2135+
ld hl, .DATA.__DATA__0
21362136
ld (__DATA_ADDR), hl
21372137
jr read_restart ; Start again
21382138
cont:
@@ -2383,7 +2383,7 @@ __09_decode_float:
23832383
ld h, a ; returns A in H; sets A free
23842384
ret
23852385
__DATA_ADDR: ;; Stores current DATA ptr
2386-
dw __DATA__0
2386+
dw .DATA.__DATA__0
23872387
ENDP
23882388
pop namespace
23892389
#line 121 "read10.bas"

tests/functional/read12.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _a:
2828
DEFB 00
2929
core.ZXBASIC_USER_DATA_END:
3030
core.__MAIN_PROGRAM__:
31-
ld hl, __DATA__1
31+
ld hl, .DATA.__DATA__1
3232
call core.__RESTORE
3333
ld a, 2
3434
call core.__READ
@@ -60,10 +60,10 @@ ___DATA__FUNCPTR__0:
6060
call core.__LOADSTR
6161
___DATA__FUNCPTR__0__leave:
6262
ret
63-
__DATA__0:
63+
.DATA.__DATA__0:
6464
DEFB 81h
6565
DEFW ___DATA__FUNCPTR__0
66-
__DATA__1:
66+
.DATA.__DATA__1:
6767
DEFB 3
6868
DEFB 1
6969
DEFB 3
@@ -1965,7 +1965,7 @@ read_restart:
19651965
or a ; 0 => OUT of data
19661966
jr nz, cont
19671967
;; Signals out of data
1968-
ld hl, __DATA__0
1968+
ld hl, .DATA.__DATA__0
19691969
ld (__DATA_ADDR), hl
19701970
jr read_restart ; Start again
19711971
cont:
@@ -2216,7 +2216,7 @@ __09_decode_float:
22162216
ld h, a ; returns A in H; sets A free
22172217
ret
22182218
__DATA_ADDR: ;; Stores current DATA ptr
2219-
dw __DATA__0
2219+
dw .DATA.__DATA__0
22202220
ENDP
22212221
pop namespace
22222222
#line 54 "read12.bas"

0 commit comments

Comments
 (0)