diff --git a/compiler/res/prog8lib/atari/syslib.p8 b/compiler/res/prog8lib/atari/syslib.p8 index e0fce6c31..277198202 100644 --- a/compiler/res/prog8lib/atari/syslib.p8 +++ b/compiler/res/prog8lib/atari/syslib.p8 @@ -1,8 +1,9 @@ ; Prog8 definitions for the Atari800XL ; Including memory registers, I/O registers, Basic and Kernal subroutines. +%option no_symbol_prefixing + atari { - %option no_symbol_prefixing &uword NMI_VEC = $FFFA ; 6502 nmi vector, determined by the kernal if banked in &uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in @@ -20,8 +21,6 @@ atari { sys { ; ------- lowlevel system routines -------- - %option no_symbol_prefixing - const ubyte target = 8 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16, 8 = atari800XL asmsub init_system() { @@ -273,8 +272,6 @@ save_SCRATCH_ZPWORD2 .word 0 } cx16 { - %option no_symbol_prefixing - ; the sixteen virtual 16-bit registers that the CX16 has defined in the zeropage ; they are simulated on the Atari as well but their location in memory is different ; TODO diff --git a/compiler/res/prog8lib/c128/syslib.p8 b/compiler/res/prog8lib/c128/syslib.p8 index 7621530c7..2215a7c80 100644 --- a/compiler/res/prog8lib/c128/syslib.p8 +++ b/compiler/res/prog8lib/c128/syslib.p8 @@ -1,9 +1,10 @@ ; Prog8 definitions for the Commodore-128 ; Including memory registers, I/O registers, Basic and Kernal subroutines. +%option no_symbol_prefixing + cbm { ; Commodore (CBM) common variables, vectors and kernal routines - %option no_symbol_prefixing &ubyte TIME_HI = $a0 ; software jiffy clock, hi byte &ubyte TIME_MID = $a1 ; .. mid byte @@ -141,7 +142,6 @@ sub CLEARST() { c64 { ; C64 I/O registers (VIC, SID, CIA) - %option no_symbol_prefixing ; the default locations of the 8 sprite pointers (store address of sprite / 64) &ubyte SPRPTR0 = 2040 @@ -296,7 +296,6 @@ c64 { c128 { ; ---- C128 specific registers ---- - %option no_symbol_prefixing &ubyte VM1 = $0A2C ; shadow for VUC $d018 in text mode &ubyte VM2 = $0A2D ; shadow for VIC $d018 in bitmap screen mode @@ -333,7 +332,6 @@ asmsub disable_basic() clobbers(A) { sys { ; ------- lowlevel system routines -------- - %option no_symbol_prefixing const ubyte target = 128 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. @@ -779,8 +777,6 @@ _longcopy } cx16 { - %option no_symbol_prefixing - ; the sixteen virtual 16-bit registers that the CX16 has defined in the zeropage ; they are simulated on the C128 as well but their location in memory is different ; (because there's no room for them in the zeropage) diff --git a/compiler/res/prog8lib/c64/floats.p8 b/compiler/res/prog8lib/c64/floats.p8 index 4dc6d7550..6d2792714 100644 --- a/compiler/res/prog8lib/c64/floats.p8 +++ b/compiler/res/prog8lib/c64/floats.p8 @@ -1,12 +1,10 @@ ; Prog8 definitions for floating point handling on the Commodore-64 -%option enable_floats +%option enable_floats, no_symbol_prefixing %import floats_functions floats { ; ---- this block contains C-64 floating point related functions ---- - %option no_symbol_prefixing - const float π = 3.141592653589793 const float PI = π const float TWOPI = 2*π diff --git a/compiler/res/prog8lib/c64/syslib.p8 b/compiler/res/prog8lib/c64/syslib.p8 index 1b5e359d4..3901c7719 100644 --- a/compiler/res/prog8lib/c64/syslib.p8 +++ b/compiler/res/prog8lib/c64/syslib.p8 @@ -1,13 +1,11 @@ ; Prog8 definitions for the Commodore-64 ; Including memory registers, I/O registers, Basic and Kernal subroutines. +%option no_symbol_prefixing cbm { - ; Commodore (CBM) common variables, vectors and kernal routines - %option no_symbol_prefixing - &ubyte TIME_HI = $a0 ; software jiffy clock, hi byte &ubyte TIME_MID = $a1 ; .. mid byte &ubyte TIME_LO = $a2 ; .. lo byte. Updated by IRQ every 1/60 sec @@ -142,8 +140,6 @@ sub CLEARST() { c64 { ; C64 I/O registers (VIC, SID, CIA) - %option no_symbol_prefixing - ; the default locations of the 8 sprite pointers (store address of sprite / 64) ; (depending on the VIC bank and screen ram address selection these can be shifted around though, ; see the two routines after this for a dynamic way of determining the correct memory location) @@ -333,8 +329,6 @@ c64 { sys { ; ------- lowlevel system routines -------- - %option no_symbol_prefixing - const ubyte target = 64 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. @@ -781,9 +775,6 @@ _longcopy } cx16 { - - %option no_symbol_prefixing - ; the sixteen virtual 16-bit registers that the CX16 has defined in the zeropage ; they are simulated on the C64 as well but their location in memory is different ; (because there's no room for them in the zeropage in the default configuration) diff --git a/compiler/res/prog8lib/cx16/floats.p8 b/compiler/res/prog8lib/cx16/floats.p8 index 759f6d08f..035b753ef 100644 --- a/compiler/res/prog8lib/cx16/floats.p8 +++ b/compiler/res/prog8lib/cx16/floats.p8 @@ -1,13 +1,11 @@ ; Prog8 definitions for floating point handling on the CommanderX16 -%option enable_floats +%option enable_floats, no_symbol_prefixing %import floats_functions floats { ; ---- this block contains C-64 compatible floating point related functions ---- - %option no_symbol_prefixing - const float π = 3.141592653589793 const float PI = π const float TWOPI = 2*π diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 38e0f3529..fdf825a31 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1,11 +1,11 @@ ; Prog8 definitions for the CommanderX16 ; Including memory registers, I/O registers, Basic and Kernal subroutines. -cbm { +%option no_symbol_prefixing +cbm { ; Commodore (CBM) common variables, vectors and kernal routines - %option no_symbol_prefixing ; STROUT --> use txt.print ; CLEARSCR -> use txt.clear_screen @@ -94,8 +94,6 @@ sub CLEARST() { cx16 { - %option no_symbol_prefixing - ; irq, system and hardware vectors: &uword IERROR = $0300 &uword IMAIN = $0302 @@ -1168,12 +1166,9 @@ sub search_x16edit() -> ubyte { } - sys { ; ------- lowlevel system routines -------- - %option no_symbol_prefixing - const ubyte target = 16 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. asmsub init_system() { diff --git a/compiler/res/prog8lib/cx16/verafx.p8 b/compiler/res/prog8lib/cx16/verafx.p8 index aebfd53fe..b44bca12c 100644 --- a/compiler/res/prog8lib/cx16/verafx.p8 +++ b/compiler/res/prog8lib/cx16/verafx.p8 @@ -1,4 +1,4 @@ -; Experimental Vera FX support. +; Somewhat experimental Vera FX support. ; Docs: ; https://github.com/X16Community/x16-docs/blob/master/VERA%20FX%20Reference.md ; https://docs.google.com/document/d/1q34uWOiM3Be2pnaHRVgSdHySI-qsiQWPTo_gfE54PTg/edit diff --git a/compiler/res/prog8lib/pet32/syslib.p8 b/compiler/res/prog8lib/pet32/syslib.p8 index 2049a10ea..4eaa08047 100644 --- a/compiler/res/prog8lib/pet32/syslib.p8 +++ b/compiler/res/prog8lib/pet32/syslib.p8 @@ -2,9 +2,10 @@ ; Including memory registers, I/O registers, Basic and Kernal subroutines. ; see: https://www.pagetable.com/?p=926 , http://www.zimmers.net/cbmpics/cbm/PETx/petmem.txt +%option no_symbol_prefixing + cbm { ; Commodore (CBM) common variables, vectors and kernal routines - %option no_symbol_prefixing &ubyte TIME_HI = $8d ; software jiffy clock, hi byte &ubyte TIME_MID = $8e ; .. mid byte @@ -79,7 +80,6 @@ asmsub RDTIM16() clobbers(X) -> uword @AY { sys { ; ------- lowlevel system routines -------- - %option no_symbol_prefixing const ubyte target = 32 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16, 32=PET @@ -364,8 +364,6 @@ save_SCRATCH_ZPWORD2 .word 0 } cx16 { - %option no_symbol_prefixing - ; the sixteen virtual 16-bit registers that the CX16 has defined in the zeropage ; they are simulated on the PET as well but their location in memory is different ; (because there's no room for them in the zeropage) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 5bf3e59f8..ba86d0a9e 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -856,7 +856,7 @@ internal class AstChecker(private val program: Program, err("using an option that is not valid for blocks") } if(directive.parent is Module) { - if(directive.args.any {it.name !in arrayOf("enable_floats", "no_sysinit", "splitarrays")}) + if(directive.args.any {it.name !in arrayOf("enable_floats", "no_sysinit", "splitarrays", "no_symbol_prefixing")}) err("using an option that is not valid for modules") } if(directive.args.any { it.name=="verafxmuls" } && compilerOptions.compTarget.name != Cx16Target.NAME) diff --git a/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt b/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt index 5482e056e..bcea7fca8 100644 --- a/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt +++ b/compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt @@ -164,7 +164,7 @@ class IntermediateAstMaker(private val program: Program, private val errors: IEr var alignment = PtBlock.BlockAlignment.NONE var forceOutput = false var veraFxMuls = false - var noSymbolPrefixing = false + var noSymbolPrefixing = "no_symbol_prefixing" in srcBlock.definingModule.options() val directives = srcBlock.statements.filterIsInstance() for (directive in directives.filter { it.directive == "%option" }) { for (arg in directive.args) { diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 6365d43dd..1ccd4cca7 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -145,8 +145,9 @@ Directives Warning: if you use this to align array variables in the block, these have to be initialized with a value to make them stay in the block and get aligned properly. Otherwise they'll end up at a random spot in the BSS section and the alignment doesn't apply there. - ``merge`` (in a block) will merge this block's contents into an already existing block with the same name. Useful in library scenarios. Can result in a bunch of unused symbol warnings, this depends on the import order. - ``splitarrays`` (block or module) makes all word-arrays in this scope lsb/msb split arrays (as if they all have the @split tag). See Arrays. - - ``no_symbol_prefixing`` (block) makes the compiler *not* use symbol-prefixing when translating prog8 code into assembly. + - ``no_symbol_prefixing`` (block or module) makes the compiler *not* use symbol-prefixing when translating prog8 code into assembly. Only use this if you know what you're doing because it could result in invalid assembly code being generated. + It can be useful when writing library modules that you don't want to be exposing prefixed assembly symbols. - ``verafxmuls`` (block, cx16 target only) uses Vera FX hardware word multiplication on the CommanderX16 for all word multiplications in this block. Warning: this may interfere with IRQs and other Vera operations, so use this only when you know what you're doing. It's safer to explicitly use ``verafx.muls()``. .. data:: %encoding