Skip to content

Commit 6bf953c

Browse files
committed
Bugfix: Enforce label definitions
ZXBasm allowed global undefined labels as long as they were not used. This is not allowed anymore.
1 parent ad20682 commit 6bf953c

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

asmparse.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,16 @@ def add_instruction(self, instr):
471471
self.__set_byte(byte, instr.lineno)
472472

473473
def dump(self):
474-
""" Returns a tuple containing code ORG, and a list of OUTPUT
474+
""" Returns a tuple containing code ORG (origin address), and a list of bytes (OUTPUT)
475475
"""
476476
org = min(self.memory_bytes.keys()) # Org is the lowest one
477477
OUTPUT = []
478478
align = []
479479

480+
for label in self.global_labels.values():
481+
if not label.defined:
482+
error(label.lineno, "Undefined GLOBAL label '%s'" % label.name)
483+
480484
for i in range(org, max(self.memory_bytes.keys()) + 1):
481485
if gl.has_errors:
482486
return org, OUTPUT
@@ -1495,7 +1499,7 @@ def generate_binary(outputfname, format_, progname='', binary_files=None, headle
14951499
import basic # Minimalist basic tokenizer
14961500

14971501
program = basic.Basic()
1498-
if org > 16383: # Only for zx48k: CLEAR if below 16383
1502+
if org > 16383: # Only for zx48k: CLEAR if above 16383
14991503
program.add_line([['CLEAR', org - 1]])
15001504
program.add_line([['LOAD', '""', program.token('CODE')]])
15011505

tests/functional/prepro35.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ __CALL_BACK__:
3232
DEFW 0
3333
3434
ZXBASIC_USER_DATA:
35+
ZXBASIC_MEM_HEAP:
3536
; Defines DATA END --> HEAP size is 0
3637
ZXBASIC_USER_DATA_END EQU ZXBASIC_MEM_HEAP
3738
; Defines USER DATA Length in bytes

tests/functional/undef_label.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
LABEL1 EQU LABEL2 + 1
3+
4+

zxbasm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from api import global_
2525

2626
# Release version
27-
VERSION = '1.13.0'
27+
VERSION = '1.13.1'
2828

2929

3030
def main(args=None):

0 commit comments

Comments
 (0)