diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt index 3bb4551fe..7cd611e0d 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt @@ -828,9 +828,10 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram, private fun funcMkword(fcall: PtBuiltinFunctionCall, resultToStack: Boolean, resultRegister: RegisterOrPair?) { if(resultToStack) { - asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.Y) // msb + asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A) // msb + asmgen.out(" pha") asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.A) // lsb - asmgen.out(" sta P8ESTACK_LO,x | tya | sta P8ESTACK_HI,x | dex") + asmgen.out(" sta P8ESTACK_LO,x | pla | sta P8ESTACK_HI,x | dex") } else { val reg = resultRegister ?: RegisterOrPair.AY var needAsave = asmgen.needAsaveForExpr(fcall.args[0])