diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt index 027f1864a..352d94e90 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt @@ -38,6 +38,7 @@ class AsmGen6502(val prefixSymbols: Boolean): ICodeGeneratorBackend { is PtBlock -> node.name = "p8b_${node.name}" is PtLabel -> node.name = "p8l_${node.name}" is PtVariable, is PtConstant, is PtMemMapped, is PtSubroutineParameter -> node.name = "p8v_${node.name}" + else -> node.name = "p8_${node.name}" } } diff --git a/compilerAst/src/prog8/compiler/CallGraph.kt b/compilerAst/src/prog8/compiler/CallGraph.kt index b3f59e609..41df866bf 100644 --- a/compilerAst/src/prog8/compiler/CallGraph.kt +++ b/compilerAst/src/prog8/compiler/CallGraph.kt @@ -163,7 +163,7 @@ class CallGraph(private val program: Program) : IAstVisitor { return allIdentifiersAndTargets.filter { decl===it.value }.map{ it.key } } - private val prefixes = listOf("p8_", "p8b_", "p8v_", "p8s_", "p8l_", "") + private val prefixes = listOf("p8b_", "p8v_", "p8s_", "p8l_", "p8_", "") private fun nameInAssemblyCode(name: String): Boolean { return allAssemblyNodes.any { prefixes.any { prefix -> prefix+name in it.names } diff --git a/docs/source/technical.rst b/docs/source/technical.rst index da5cc5ff9..2c35b0787 100644 --- a/docs/source/technical.rst +++ b/docs/source/technical.rst @@ -32,16 +32,21 @@ Symbol prefixing in generated Assembly code *All* symbols in the prog8 program will be prefixed in the generated assembly code: -Block names - will be prefixed with ``p8b_`` -All other names - will be prefixed with ``p8_`` +============ ======== +Element type prefix +============ ======== +Block ``p8b_`` +Subroutine ``p8s_`` +Variable ``p8v_`` +Label ``p8l_`` +other ``p8_`` +============ ======== This is to avoid naming conflicts with CPU registers, assembly instructions, etc. So if you're referencing symbols from the prog8 program in inlined assembly code, you have to take -this into account. Stick a ``p8_`` in front of everything (``p8b_`` for block names) that you want to reference that is coming +this into account. Stick the proper prefix in front of every symbol name component that you want to reference that is coming from a prog8 source file. -All elements in scoped names such as ``main.routine.var1`` are prefixed so this becomes ``p8b_main.p8_routine.p8_var1``. +All elements in scoped names such as ``main.routine.var1`` are prefixed so this becomes ``p8b_main.p8s_routine.p8v_var1``. .. attention:: Symbols from library modules are *not* prefixed and can be used diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 19b882de1..b8270d4e2 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,9 +2,6 @@ TODO ==== -- also change asm subroutine and variable prefixes from `p8_` to `p8s_` / `p8v_` and be done with it once and for all. - - - verafx vram-vram copy routine? set the cache fill and cache write bits in fx ctrl, set one data port's increment to 1 and the other one to 4, Assuming your writes are aligned to 32-bit boundaries, do four reads from the increment-1 port