Skip to content

Commit 93cb553

Browse files
committed
Fix wrong line number within asm context
1 parent 68ccf05 commit 93cb553

7 files changed

Lines changed: 71 additions & 10 deletions

File tree

src/arch/zx48k/backend/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ def _memcopy(ins):
17671767
def _inline(ins):
17681768
""" Inline code
17691769
"""
1770-
tmp = [x.strip(' \t\r\n') for x in ins.quad[1].split('\n')] # Split lines
1770+
tmp = [x.strip(' \t\r') for x in ins.quad[1].split('\n')] # Split lines
17711771

17721772
i = 0
17731773
while i < len(tmp):
@@ -1789,12 +1789,7 @@ def _inline(ins):
17891789
i += 1
17901790
continue
17911791

1792-
if len(tmp[i][-1]) == ':':
1793-
i += 1
1794-
continue # This is already a single label
1795-
1796-
tmp[i] = tmp[i][match.end() + 1:].strip(' \n')
1797-
tmp.insert(i, match.group())
1792+
# It starts with a label. Do not tabulate
17981793
i += 1
17991794

18001795
output = []

src/libzxbc/zxblex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def t_asm_ASM(t):
415415

416416
t.lexer.begin('INITIAL')
417417
t.value = ASM
418-
t.lineno = ASMLINENO - 1
418+
t.lineno = ASMLINENO
419419
IN_STATE = False
420420

421421
return t
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
ZXBASIC_USER_DATA_END:
20+
__MAIN_PROGRAM__:
21+
#line 2 "asm_error_line.bas"
22+
test: dk 10, 20
23+
#line 6 "asm_error_line.bas"
24+
#line 6 "asm_error_line.bas"
25+
dk 10, 20
26+
#line 10 "asm_error_line.bas"
27+
ld hl, 0
28+
ld b, h
29+
ld c, l
30+
__END_PROGRAM:
31+
di
32+
ld hl, (__CALL_BACK__)
33+
ld sp, hl
34+
exx
35+
pop hl
36+
exx
37+
pop iy
38+
pop ix
39+
ei
40+
ret
41+
__CALL_BACK__:
42+
DEFW 0
43+
;; --- end of user code ---
44+
END
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
ASM
3+
test: dk 10, 20
4+
END ASM
5+
6+
ASM
7+
dk 10, 20
8+
END ASM
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
ASM
3+
test: dk 10, 20
4+
END ASM
5+
6+
ASM
7+
dk 10, 20
8+
END ASM
9+

tests/functional/test_cmdline.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ no_zxnext.asm:29: error: Syntax error. Unexpected token 'C' [C]
3737
define_val.bas:4: error: "MACRO should be VALUE"
3838

3939
>>> process_file('tap_include_asm_error.bas', ['-q', '-S'])
40-
extra_chars.bas:1: error: illegal character '`'
41-
extra_chars.bas:2: error: illegal character '#'
40+
extra_chars.bas:2: error: illegal character '`'
41+
extra_chars.bas:3: error: illegal character '#'
42+
4243

tests/functional/test_errmsg.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,7 @@ doloop2.bas:4: warning: [W150] Variable 'a' is never used
194194
>>> process_file('line_number_after_macro.bas')
195195
line_number_after_macro.bas:8: warning: Using default implicit type 'float' for 'a'
196196
line_number_after_macro.bas:11: error: Syntax Error. Unexpected token '+' <PLUS>
197+
>>> process_file('tap_asm_error_line.bas', ['-S', '-q'])
198+
tap_asm_error_line.bas:2: error: Syntax error. Unexpected token '10' [INTEGER]
199+
tap_asm_error_line.bas:6: error: Syntax error. Unexpected token '10' [INTEGER]
197200

0 commit comments

Comments
 (0)