1
0
mirror of https://github.com/irmen/prog8.git synced 2025-04-28 04:37:46 +00:00

changed -sourcelines option to -nosourcelines (default is now to include them)

This commit is contained in:
Irmen de Jong 2025-02-12 20:55:09 +01:00
parent 2aeb7a838e
commit fc03d6f332
9 changed files with 28 additions and 37 deletions
codeCore/src/prog8/code/target
compiler
src/prog8
test/comparisons
docs/source
examples

@ -148,7 +148,9 @@ class ConfigFileTarget(
override fun getFloatAsmBytes(num: Number) = TODO("floats")
override fun convertFloatToBytes(num: Double): List<UByte> = TODO("floats")
override fun convertBytesToFloat(bytes: List<UByte>): 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 }

@ -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<String>): 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<String>): 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<String>): 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<String>): 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)
}
}

@ -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

@ -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 <pathlist>``
Specify a list of extra paths (separated with ':'), to search in for imported modules.

@ -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.

@ -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

@ -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

@ -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

@ -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<x
return
}
}