fix bug where non-inlined asmsub didn't always get a proper RTS, causing program crash

was caused by a change in 7.8; 8ae3bad6f7 "fix rts in empty asmsub"
This commit is contained in:
Irmen de Jong 2022-03-03 01:10:33 +01:00
parent 2812736ae5
commit 094ecceaac
2 changed files with 2 additions and 5 deletions

View File

@ -118,7 +118,7 @@ internal class BeforeAsmAstChanger(val program: Program,
// add the implicit return statement at the end (if it's not there yet), but only if it's not a kernal routine.
// and if an assembly block doesn't contain a rts/rti, and some other situations.
if (!subroutine.isAsmSubroutine && !subroutine.inline) {
if (!subroutine.isAsmSubroutine && (!subroutine.inline || !options.optimize)) {
if(subroutine.statements.isEmpty() ||
(subroutine.amountOfRtsInAsm() == 0
&& subroutine.statements.lastOrNull { it !is VarDecl } !is Return
@ -145,7 +145,7 @@ internal class BeforeAsmAstChanger(val program: Program,
}
}
if (!subroutine.inline) {
if (!subroutine.inline || !options.optimize) {
if (subroutine.isAsmSubroutine && subroutine.asmAddress==null && subroutine.amountOfRtsInAsm() == 0) {
// make sure the NOT INLINED asm subroutine actually has a rts at the end
// (non-asm routines get a Return statement as needed, above)

View File

@ -3,9 +3,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
FIX BUG:
- wormfood noopt crash caused by a change in 7.8; 8ae3bad6f7e73a3913594a983939298b357c7e7e "fix rts in empty asmsub"
...