diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index b6557898b..cafce0d3c 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -137,6 +137,9 @@ internal class AstChecker(private val program: Program, errors.err("word loop variable can only loop over bytes or words", forLoop.position) } DataType.FLOAT -> { + // Looping over float variables is very inefficient because the loopvar is going to + // get copied over with new values all the time. We don't support this for now. + // Loop with an integer index variable if you really need to... or write different code. errors.err("for loop only supports integers", forLoop.position) } else -> errors.err("loop variable must be numeric type", forLoop.position) diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt index c6ab9bfa9..3ff00f288 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt @@ -513,12 +513,14 @@ internal class AsmGen(private val program: Program, return if(targetScope !== identScope) { val scopedName = getScopedSymbolNameForTarget(identifier.nameInSource.last(), target) if(target is Label) { + // make labels locally scoped in the asm. Is slightly problematic, see github issue #62 val last = scopedName.removeLast() scopedName.add("_$last") } fixNameSymbols(scopedName.joinToString(".")) } else { if(target is Label) { + // make labels locally scoped in the asm. Is slightly problematic, see github issue #62 val scopedName = identifier.nameInSource.toMutableList() val last = scopedName.removeLast() scopedName.add("_$last") @@ -1232,7 +1234,8 @@ $repeatLabel lda $counterVar } private fun translate(stmt: Label) { - out("_${stmt.name}") // underscore prefix to make sure it's a local label + // underscore prefix to make sure it's a local label. Is slightly problematic, see github issue #62 + out("_${stmt.name}") } private fun translate(scope: AnonymousScope) { diff --git a/examples/test.p8 b/examples/test.p8 index 7ff6e37be..b1146ae87 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,12 +1,14 @@ %import textio -%import test_stack -%zeropage basicsafe main { - sub start() { - %asminclude "fozsdfsdf.asm" + str myBar = "main.bar" - txt.print("ok") - test_stack.test() - } +foo_bar: + %asminclude "compiler/test/fixtures/foo_bar.asm" ; FIXME: should be accessible from inside start() but give assembler error + + sub start() { + txt.print(myBar) + txt.print(&foo_bar) + return + } }