diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index 820df9dcb..27ebe5c1e 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -264,7 +264,14 @@ internal fun determineProgramLoadAddress(program: Program, options: CompilationO } options.loadAddress = loadAddress + options.memtopAddress = program.toplevelModule.memtopAddress?.first ?: options.compTarget.machine.PROGRAM_MEMTOP_ADDRESS + + if(loadAddress>options.memtopAddress) { + errors.warn("program load address ${loadAddress.toHex()} is beyond default memtop address ${options.memtopAddress.toHex()}. " + + "Memtop has been adjusted to ${'$'}ffff to avoid assembler error. Set a valid %memtop yourself to get rid of this warning.", program.toplevelModule.position) + options.memtopAddress = 0xffffu + } } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c3225e497..6ae4c515d 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,8 +3,6 @@ TODO make repeat support 65536 iterations -make memtop adjust automatically when you use %address larger than the default . Then simply set it at $ffff because apparently the programmer knows better? - scripts/cx16_images : add an option to keep the first palette entry black (there's already the option to retain the first 16 entries) support this usage of defer: diff --git a/examples/test.p8 b/examples/test.p8 index ab3414a41..4d8a5037d 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,16 +1,12 @@ %import textio -%zeropage basicsafe %option no_sysinit +%zeropage basicsafe +%address $f200 +%output raw +%launcher none main { sub start() { - repeat 100 { - cx16.r0++ - if cx16.r0!=0 - goto mylabel - } - -mylabel: - + txt.print_uwhex(cbm.MEMTOP(0, true), true) } }