Skip to content

Commit 094ecce

Browse files
committed
fix bug where non-inlined asmsub didn't always get a proper RTS, causing program crash
was caused by a change in 7.8; 8ae3bad "fix rts in empty asmsub"
1 parent 2812736 commit 094ecce

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ internal class BeforeAsmAstChanger(val program: Program,
118118

119119
// add the implicit return statement at the end (if it's not there yet), but only if it's not a kernal routine.
120120
// and if an assembly block doesn't contain a rts/rti, and some other situations.
121-
if (!subroutine.isAsmSubroutine && !subroutine.inline) {
121+
if (!subroutine.isAsmSubroutine && (!subroutine.inline || !options.optimize)) {
122122
if(subroutine.statements.isEmpty() ||
123123
(subroutine.amountOfRtsInAsm() == 0
124124
&& subroutine.statements.lastOrNull { it !is VarDecl } !is Return
@@ -145,7 +145,7 @@ internal class BeforeAsmAstChanger(val program: Program,
145145
}
146146
}
147147

148-
if (!subroutine.inline) {
148+
if (!subroutine.inline || !options.optimize) {
149149
if (subroutine.isAsmSubroutine && subroutine.asmAddress==null && subroutine.amountOfRtsInAsm() == 0) {
150150
// make sure the NOT INLINED asm subroutine actually has a rts at the end
151151
// (non-asm routines get a Return statement as needed, above)

docs/source/todo.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ TODO
33

44
For next release
55
^^^^^^^^^^^^^^^^
6-
FIX BUG:
7-
- wormfood noopt crash caused by a change in 7.8; 8ae3bad6f7e73a3913594a983939298b357c7e7e "fix rts in empty asmsub"
8-
96
...
107

118

0 commit comments

Comments
 (0)