fix invalid asm addressing mode for certain value-to-evalstack transfers

This commit is contained in:
Irmen de Jong 2021-11-04 22:44:31 +01:00
parent be73739c62
commit f09c04eeac
2 changed files with 6 additions and 4 deletions

View File

@ -41,11 +41,12 @@ internal class AsmAssignTarget(val kind: TargetStorageKind,
{ {
val constMemoryAddress by lazy { memory?.addressExpression?.constValue(program)?.number?.toInt() ?: 0} val constMemoryAddress by lazy { memory?.addressExpression?.constValue(program)?.number?.toInt() ?: 0}
val constArrayIndexValue by lazy { array?.indexer?.constIndex() } val constArrayIndexValue by lazy { array?.indexer?.constIndex() }
val asmVarname: String val asmVarname: String by lazy {
get() = if(array==null) if (array == null)
variableAsmName!! variableAsmName!!
else else
asmgen.asmVariableName(array.arrayvar) asmgen.asmVariableName(array.arrayvar)
}
lateinit var origAssign: AsmAssignment lateinit var origAssign: AsmAssignment

View File

@ -949,7 +949,8 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
lda #<$sourceName lda #<$sourceName
ldy #>$sourceName+1 ldy #>$sourceName+1
sta P8ESTACK_LO,x sta P8ESTACK_LO,x
sty P8ESTACK_HI,x tya
sta P8ESTACK_HI,x
dex""") dex""")
} }
else -> throw AssemblyError("string-assign to weird target") else -> throw AssemblyError("string-assign to weird target")
@ -1581,7 +1582,7 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
} }
TargetStorageKind.STACK -> { TargetStorageKind.STACK -> {
when(regs) { when(regs) {
RegisterOrPair.AY -> asmgen.out(" sta P8ESTACK_LO,x | sty P8ESTACK_HI,x | dex") RegisterOrPair.AY -> asmgen.out(" sta P8ESTACK_LO,x | tya | sta P8ESTACK_HI,x | dex")
RegisterOrPair.AX, RegisterOrPair.XY -> throw AssemblyError("can't use X here") RegisterOrPair.AX, RegisterOrPair.XY -> throw AssemblyError("can't use X here")
in Cx16VirtualRegisters -> { in Cx16VirtualRegisters -> {
val srcReg = asmgen.asmSymbolName(regs) val srcReg = asmgen.asmSymbolName(regs)