pet32: don't use problematic zeropage locations

This commit is contained in:
Irmen de Jong committed 2026-07-04 00:03:22 +02:00
1 parent 5130a74754
commit c3ec400ee7
6 files changed
+20 -22

No files matched your search

@@ -32,7 +32,10 @@ class PETZeropage(options: CompilationOptions) : Zeropage(options) {
}
ZeropageType.FLOATSAFE,
ZeropageType.BASICSAFE -> {
free.addAll(0xb1u..0xbau) // TODO more?
// Only scratch register area is safe for transient use.
// $b5 and $ba are clobbered by PET BASIC/Kernal calls like CHROUT ($ffd2).
// User variables requiring persistent storage must NOT be placed here.
free.addAll(listOf(0xb1u, 0xb2u, 0xb3u, 0xb4u, 0xb6u, 0xb7u, 0xb8u, 0xb9u))
}
ZeropageType.DONTUSE -> {
free.clear() // don't use zeropage at all
@@ -83,4 +86,4 @@ class PETZeropage(options: CompilationOptions) : Zeropage(options) {
allocatedVariables["cx16.r12r13sl"] = VarAllocation((base+6*4).toUInt(), DataType.LONG, 4)
allocatedVariables["cx16.r14r15sl"] = VarAllocation((base+7*4).toUInt(), DataType.LONG, 4)
}
}
}