fix pointer write outside zeropage

This commit is contained in:
Irmen de Jong 2021-02-21 16:22:44 +01:00
parent b5289511ba
commit 00d735249b
2 changed files with 13 additions and 15 deletions

View File

@ -1412,13 +1412,15 @@ $label nop""")
when(ptrAndIndex.second) {
is NumericLiteralValue, is IdentifierReference -> {
if(pointervar!=null && isZpVar(pointervar)) {
out(" pha")
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
out(" sta (${asmSymbolName(pointervar)}),y")
out(" pla | sta (${asmSymbolName(pointervar)}),y")
} else {
// copy the pointer var to zp first
out(" pha")
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
out(" sta (P8ZP_SCRATCH_W2),y")
out(" pla | sta (P8ZP_SCRATCH_W2),y")
}
}
else -> {
@ -1426,15 +1428,13 @@ $label nop""")
if(pointervar!=null && isZpVar(pointervar)) {
out(" pha")
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
out(" pla")
out(" sta (${asmSymbolName(pointervar)}),y")
out(" pla | sta (${asmSymbolName(pointervar)}),y")
} else {
// copy the pointer var to zp first
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
out(" pha")
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
out(" pla")
out(" sta (P8ZP_SCRATCH_W2),y")
out(" pla | sta (P8ZP_SCRATCH_W2),y")
}
}
}

View File

@ -1,21 +1,19 @@
%import textio
%zeropage basicsafe
%zeropage dontuse
%option no_sysinit
main {
; $1F9C0 - $1F9FF PSG registers
sub init(uword addr, ubyte length) {
@(addr+length) = $ea
}
sub start() {
ubyte xx = '?'
when xx {
'a' -> txt.print("a\n")
'b' -> txt.print("b\n")
'?' -> {
}
else -> txt.print("else\n")
}
init($4000, 0)
txt.print_uwhex(@($4000), true)
; uword freq = 1181
; cx16.vpoke(1, $f9c0, lsb(freq))