diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt index 25eaba7cd..e1d88b83f 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt @@ -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)