mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 05:29:38 +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) {
|
when(ptrAndIndex.second) {
|
||||||
is NumericLiteralValue, is IdentifierReference -> {
|
is NumericLiteralValue, is IdentifierReference -> {
|
||||||
if(pointervar!=null && isZpVar(pointervar)) {
|
if(pointervar!=null && isZpVar(pointervar)) {
|
||||||
|
out(" pha")
|
||||||
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
||||||
out(" sta (${asmSymbolName(pointervar)}),y")
|
out(" pla | sta (${asmSymbolName(pointervar)}),y")
|
||||||
} else {
|
} else {
|
||||||
// copy the pointer var to zp first
|
// copy the pointer var to zp first
|
||||||
|
out(" pha")
|
||||||
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
|
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
|
||||||
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
||||||
out(" sta (P8ZP_SCRATCH_W2),y")
|
out(" pla | sta (P8ZP_SCRATCH_W2),y")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
@ -1426,15 +1428,13 @@ $label nop""")
|
|||||||
if(pointervar!=null && isZpVar(pointervar)) {
|
if(pointervar!=null && isZpVar(pointervar)) {
|
||||||
out(" pha")
|
out(" pha")
|
||||||
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
||||||
out(" pla")
|
out(" pla | sta (${asmSymbolName(pointervar)}),y")
|
||||||
out(" sta (${asmSymbolName(pointervar)}),y")
|
|
||||||
} else {
|
} else {
|
||||||
// copy the pointer var to zp first
|
// copy the pointer var to zp first
|
||||||
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
|
assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null)
|
||||||
out(" pha")
|
out(" pha")
|
||||||
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y)
|
||||||
out(" pla")
|
out(" pla | sta (P8ZP_SCRATCH_W2),y")
|
||||||
out(" sta (P8ZP_SCRATCH_W2),y")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage dontuse
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
; $1F9C0 - $1F9FF PSG registers
|
; $1F9C0 - $1F9FF PSG registers
|
||||||
|
|
||||||
|
sub init(uword addr, ubyte length) {
|
||||||
|
@(addr+length) = $ea
|
||||||
|
}
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
ubyte xx = '?'
|
init($4000, 0)
|
||||||
when xx {
|
txt.print_uwhex(@($4000), true)
|
||||||
'a' -> txt.print("a\n")
|
|
||||||
'b' -> txt.print("b\n")
|
|
||||||
'?' -> {
|
|
||||||
}
|
|
||||||
else -> txt.print("else\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
; uword freq = 1181
|
; uword freq = 1181
|
||||||
; cx16.vpoke(1, $f9c0, lsb(freq))
|
; cx16.vpoke(1, $f9c0, lsb(freq))
|
||||||
|
Loading…
Reference in New Issue
Block a user