mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
fix pointer write outside zeropage
This commit is contained in:
parent
b5289511ba
commit
00d735249b
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user