Skip to content

Commit 2ce9f46

Browse files
committed
bugfix: do not remove asm block upon jump
ASM blocks are NEVER optimized
1 parent 13a7656 commit 2ce9f46

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

arch/zx48k/backend/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,8 @@ def output_join(output, new_chunk):
27162716
# <any inst>
27172717
# Into:
27182718
# jp XXX
2719-
if OPT31 and i1 == 'jp' and not condition(output[-1]) and i2 is not None and i2[-1] != ':':
2719+
if OPT31 and i1 == 'jp' and not condition(output[-1]) and i2 is not None and \
2720+
i2[-1] != ':' and new_chunk[0] not in ASMS:
27202721
new_chunk.pop(0)
27212722
changed = True
27222723
continue

tests/functional/opt1_nolabel.asm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
#line 1
14+
ld hl, mygod
15+
#line 2
16+
jp __LABEL__finish
17+
mygod:
18+
nop
19+
#line 9
20+
__LABEL__finish:
21+
ld hl, 0
22+
ld b, h
23+
ld c, l
24+
__END_PROGRAM:
25+
di
26+
ld hl, (__CALL_BACK__)
27+
ld sp, hl
28+
exx
29+
pop hl
30+
exx
31+
pop iy
32+
pop ix
33+
ei
34+
ret
35+
__CALL_BACK__:
36+
DEFW 0
37+
38+
ZXBASIC_USER_DATA:
39+
; Defines DATA END --> HEAP size is 0
40+
ZXBASIC_USER_DATA_END EQU ZXBASIC_MEM_HEAP
41+
; Defines USER DATA Length in bytes
42+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
43+
END

tests/functional/opt1_nolabel.bas

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
ASM
3+
ld hl, mygod
4+
END ASM
5+
6+
GOTO finish
7+
8+
ASM
9+
mygod:
10+
nop
11+
END ASM
12+
13+
finish:
14+

0 commit comments

Comments
 (0)