fix possible register corruption when calling asmsubs that require Carry flag as a parameter

This commit is contained in:
Irmen de Jong 2023-09-24 14:03:31 +02:00
parent 1da0c59182
commit 8d177beb78

View File

@ -141,13 +141,14 @@ internal class FunctionCallAsmGen(private val program: PtProgram, private val as
}
is PtIdentifier -> {
val sourceName = asmgen.asmVariableName(value)
// note: cannot use X register here to store A because it might be used for other arguments
asmgen.out("""
tax
pha
clc
lda $sourceName
beq +
sec
+ txa""")
+ pla""")
}
else -> {
asmgen.assignExpressionToRegister(value, RegisterOrPair.A)