diff --git a/codeCore/src/prog8/code/target/ConfigFileTarget.kt b/codeCore/src/prog8/code/target/ConfigFileTarget.kt index 2be7a0c58..3228a8cd3 100644 --- a/codeCore/src/prog8/code/target/ConfigFileTarget.kt +++ b/codeCore/src/prog8/code/target/ConfigFileTarget.kt @@ -148,7 +148,9 @@ class ConfigFileTarget( override fun getFloatAsmBytes(num: Number) = TODO("floats") override fun convertFloatToBytes(num: Double): List = TODO("floats") override fun convertBytesToFloat(bytes: List): Double = TODO("floats") - override fun launchEmulator(selectedEmulator: Int, programNameWithPath: Path) = TODO("emulator") + override fun launchEmulator(selectedEmulator: Int, programNameWithPath: Path) { + throw IllegalArgumentException("Custom compiler target cannot automatically launch an emulator. Do this manually.") + } override fun isIOAddress(address: UInt): Boolean = ioAddresses.any { address in it } diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index 5ffdd8851..1b04d878a 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -2,7 +2,6 @@ package prog8 import kotlinx.cli.* import prog8.ast.AstException -import prog8.code.core.CbmPrgLauncherType import prog8.code.source.ImportFileSystem.expandTilde import prog8.code.target.CompilationTargets import prog8.code.target.Cx16Target @@ -67,7 +66,7 @@ private fun compileMain(args: Array): Boolean { val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results") val slabsGolden by cli.option(ArgType.Boolean, fullName = "slabsgolden", description = "put memory() slabs in 'golden ram' memory area instead of at the end of the program. On the cx16 target this is $0400-07ff. This is unavailable on other systems.") val slabsHighBank by cli.option(ArgType.Int, fullName = "slabshigh", description = "put memory() slabs in high memory area instead of at the end of the program. On the cx16 target the value specifies the HiRAM bank to use, on other systems this value is ignored.") - val includeSourcelines by cli.option(ArgType.Boolean, fullName = "sourcelines", description = "include original Prog8 source lines in generated asm code") + val dontIncludeSourcelines by cli.option(ArgType.Boolean, fullName = "nosourcelines", description = "do not include original Prog8 source lines in generated asm code") val dontSplitWordArrays by cli.option(ArgType.Boolean, fullName = "dontsplitarrays", description = "don't store any word array as split lsb/msb in memory, as if all of those have @nosplit") val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator) val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of ${CompilationTargets.joinToString(",")} or a custom target properties file) (required)") @@ -172,7 +171,7 @@ private fun compileMain(args: Array): Boolean { warnSymbolShadowing == true, quietAssembler == true, asmListfile == true, - includeSourcelines == true, + dontIncludeSourcelines != true, experimentalCodegen == true, dumpVariables == true, dumpSymbols == true, @@ -255,7 +254,7 @@ private fun compileMain(args: Array): Boolean { warnSymbolShadowing == true, quietAssembler == true, asmListfile == true, - includeSourcelines == true, + dontIncludeSourcelines != true, experimentalCodegen == true, dumpVariables == true, dumpSymbols==true, @@ -296,16 +295,10 @@ private fun compileMain(args: Array): Boolean { val programNameInPath = outputPath.resolve(compilationResult.compilerAst.name) - if(startEmulator1==true || startEmulator2==true) { - if (compilationResult.compilationOptions.launcher != CbmPrgLauncherType.NONE || compilationTarget=="atari" || compilationTarget=="neo") { - if (startEmulator1 == true) - compilationResult.compilationOptions.compTarget.launchEmulator(1, programNameInPath) - else if (startEmulator2 == true) - compilationResult.compilationOptions.compTarget.launchEmulator(2, programNameInPath) - } else { - println("\nCan't start emulator because program has no launcher type.") - } - } + if (startEmulator1 == true) + compilationResult.compilationOptions.compTarget.launchEmulator(1, programNameInPath) + else if (startEmulator2 == true) + compilationResult.compilationOptions.compTarget.launchEmulator(2, programNameInPath) } } diff --git a/compiler/test/comparisons/Makefile b/compiler/test/comparisons/Makefile index a6a110947..c0236143a 100644 --- a/compiler/test/comparisons/Makefile +++ b/compiler/test/comparisons/Makefile @@ -12,7 +12,7 @@ generate: python make_eq_tests_splitw.py python make_cmp_tests.py python make_cmp_tests_splitw.py - prog8c -target cx16 -sourcelines *.p8 >/dev/null + prog8c -target cx16 *.p8 >/dev/null test_prgs: x16emu -run -prg ifelse.prg diff --git a/docs/source/compiling.rst b/docs/source/compiling.rst index c66e2b9cd..c7ac2513c 100644 --- a/docs/source/compiling.rst +++ b/docs/source/compiling.rst @@ -218,10 +218,9 @@ One or more .p8 module files put memory() slabs in high memory area instead of at the end of the program. On the cx16 target the value specifies the HiRAM bank to use, on other systems this value is ignored. -``-sourcelines`` - Also include the original prog8 source code lines as comments in the generated assembly code file, - mixed in between the actual generated assembly code. - This can be useful for debugging purposes to see what assembly was generated for what prog8 source code. +``-nosourcelines`` + Do not include the original prog8 source code lines as comments in the generated assembly code file, + mixed in between the actual generated assembly code. The default behavior is to include the sourcel lines. ``-srcdirs `` Specify a list of extra paths (separated with ':'), to search in for imported modules. diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 4a594ad92..a5a3d32ae 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -7,14 +7,9 @@ TODO Future Things and Ideas ^^^^^^^^^^^^^^^^^^^^^^^ -- Improve compilation target configurability: emulator binary/cmdline? - neo6502 emulator: "neo hello.bin@800 cold" - atari emulators: "atari800 -xl -xl-rev 2 -nobasic -run hello.xex >/dev/null 2>/dev/null" or second one: "Altirra64.exe hello.xex" - -- Look at github PR for improved romability +- Look at github PR for improved romability (see github issue 149) - Kotlin: can we use inline value classes in certain spots? - add float support to the configurable compiler targets -- improve support for romable code (see github issue 149) - Improve the SublimeText syntax file for prog8, you can also install this for 'bat': https://github.com/sharkdp/bat?tab=readme-ov-file#adding-new-syntaxes--language-definitions - [problematic due to using 64tass:] better support for building library programs, where unused .proc are NOT deleted from the assembly. Perhaps replace all uses of .proc/.pend/.endproc by .block/.bend will fix that with a compiler flag? @@ -75,7 +70,7 @@ Libraries Optimizations ------------- -- can we optimize const uword in expressions that is actually small enough for ubyte? Like const uword x=128 if var>x ... +- can we optimize const uword in expressions that is actually small enough for ubyte? Like const uword x=128 if bytevar>x ... - Compare output of some Oscar64 samples to what prog8 does for the equivalent code (see https://github.com/drmortalwombat/OscarTutorials/tree/main and https://github.com/drmortalwombat/oscar64/tree/main/samples) - Multi-value returns of normal subroutines: use cpu register A or AY for the first one and only start using virtual registers for the rest. Can FAC then be used for floats as well again? Those are now not supported for multi-value returns. diff --git a/examples/customtarget/Makefile b/examples/customtarget/Makefile index ec3902bcc..39ab78d84 100644 --- a/examples/customtarget/Makefile +++ b/examples/customtarget/Makefile @@ -6,15 +6,15 @@ clean: rm -f *.prg *.PRG *.xex *.bin *.asm *.vice-* main-c64.prg: src/main.p8 targetconfigs/tinyc64.properties - prog8c -target targetconfigs/tinyc64.properties src/main.p8 -sourcelines + prog8c -target targetconfigs/tinyc64.properties src/main.p8 mv main.prg $@ main-cx16.prg: src/main.p8 targetconfigs/tinycx16.properties - prog8c -target targetconfigs/tinycx16.properties src/main.p8 -sourcelines + prog8c -target targetconfigs/tinycx16.properties src/main.p8 mv main.prg $@ main-pet.prg: src/main.p8 targetconfigs/tinypet.properties - prog8c -target targetconfigs/tinypet.properties src/main.p8 -sourcelines + prog8c -target targetconfigs/tinypet.properties src/main.p8 mv main.prg $@ atari-hello.xex: src/atari-hello.p8 diff --git a/examples/customtarget/targetconfigs/atari.properties b/examples/customtarget/targetconfigs/atari.properties index bd8eeb018..4e7d480dd 100644 --- a/examples/customtarget/targetconfigs/atari.properties +++ b/examples/customtarget/targetconfigs/atari.properties @@ -1,4 +1,5 @@ # configuration file for a C64 like Prog8 compilation target +# launch the atari emulator like this: "atari800 -xl -xl-rev 2 -nobasic -run hello.xex >/dev/null 2>/dev/null" or second one: "Altirra64.exe hello.xex" cpu = 6502 encoding = atascii diff --git a/examples/customtarget/targetconfigs/neo6502.properties b/examples/customtarget/targetconfigs/neo6502.properties index 9a6f619b6..4f6ad79e5 100644 --- a/examples/customtarget/targetconfigs/neo6502.properties +++ b/examples/customtarget/targetconfigs/neo6502.properties @@ -1,4 +1,5 @@ # configuration file for a C64 like Prog8 compilation target +# launch the neo6502 emulator like this: "neo hello.bin@800 cold" cpu = 65C02 encoding = iso diff --git a/examples/test.p8 b/examples/test.p8 index 1108e07c9..71b592a36 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,13 +4,13 @@ main { sub start() { - func($11,$22,$33,$44) - } + const uword x=128 - sub func(ubyte arg1, ubyte arg2 @R1, ubyte arg3 @R2, ubyte arg4) { - txt.print_ubhex(arg1, false) - txt.print_ubhex(arg2, false) - txt.print_ubhex(arg3, false) - txt.print_ubhex(arg4, false) + if cx16.r0L==x + return + if cx16.r0L>x + return + if cx16.r0L