Skip to content

Commit

Permalink
fix bug where non-inlined asmsub didn't always get a proper RTS, caus…
Browse files Browse the repository at this point in the history
…ing program crash

 was caused by a change in 7.8; 8ae3bad "fix rts in empty asmsub"
  • Loading branch information
irmen committed Mar 3, 2022
1 parent 2812736 commit 094ecce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions docs/source/todo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"

...


Expand Down

0 comments on commit 094ecce

Please sign in to comment.