fix if-gosub

This commit is contained in:
Irmen de Jong 2021-12-28 01:24:31 +01:00
parent 1c7c4fc3b0
commit 79405f47f6
2 changed files with 7 additions and 6 deletions

View File

@ -1098,8 +1098,9 @@ class AsmGen(private val program: Program,
val booleanCondition = stmt.condition as BinaryExpression val booleanCondition = stmt.condition as BinaryExpression
if (stmt.elsepart.isEmpty()) { if (stmt.elsepart.isEmpty()) {
if(stmt.truepart.statements.singleOrNull() is Jump) { val jump = stmt.truepart.statements.singleOrNull()
translateCompareAndJumpIfTrue(booleanCondition, stmt.truepart.statements[0] as Jump) if(jump is Jump && !jump.isGosub) {
translateCompareAndJumpIfTrue(booleanCondition, jump)
} else { } else {
val endLabel = makeLabel("if_end") val endLabel = makeLabel("if_end")
translateCompareAndJumpIfFalse(booleanCondition, endLabel) translateCompareAndJumpIfFalse(booleanCondition, endLabel)
@ -1612,6 +1613,8 @@ $label nop""")
} }
private fun translateCompareAndJumpIfTrue(expr: BinaryExpression, jump: Jump) { private fun translateCompareAndJumpIfTrue(expr: BinaryExpression, jump: Jump) {
require(!jump.isGosub)
if(expr.operator !in ComparisonOperators) if(expr.operator !in ComparisonOperators)
throw AssemblyError("must be comparison expression") throw AssemblyError("must be comparison expression")

View File

@ -3,10 +3,8 @@ TODO
For next compiler release (7.6) For next compiler release (7.6)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fix imageviewer pcx decoding, broken since if/goto changes... fix imageviewer crashes...
also wormfood: worm freezes when you press fire... also textelite: after showing map, it continues to show the market without keyboard entry...
also petaxian: gameplay doesn't work at all anymore
also textelite: after showing map, it just exits
Blocked by an official Commander-x16 v39 release Blocked by an official Commander-x16 v39 release