added -breakinstr compiler option

This commit is contained in:
Irmen de Jong 2023-10-15 21:55:09 +02:00
parent 203ec5fa46
commit daca87c6d0
11 changed files with 34 additions and 7 deletions

View File

@ -21,6 +21,7 @@ class CompilationOptions(val output: OutputType,
var experimentalCodegen: Boolean = false,
var varsHighBank: Int? = null,
var splitWordArrays: Boolean = false,
var breakpointCpuInstruction: Boolean = false,
var outputDir: Path = Path(""),
var symbolDefs: Map<String, String> = emptyMap()
) {

View File

@ -1026,6 +1026,15 @@ $repeatLabel""")
val label = "_prog8_breakpoint_${breakpointLabels.size+1}"
breakpointLabels.add(label)
out(label)
if(options.breakpointCpuInstruction) {
val instruction =
when(options.compTarget.machine.cpu) {
CpuType.CPU6502 -> "brk"
CpuType.CPU65c02 -> "stp"
else -> throw AssemblyError("invalid cpu type")
}
out(" $instruction")
}
}
internal fun signExtendAYlsb(valueDt: DataType) {

View File

@ -49,6 +49,7 @@ private fun compileMain(args: Array<String>): Boolean {
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 includeSourcelines by cli.option(ArgType.Boolean, fullName = "sourcelines", description = "include original Prog8 source lines in generated asm code")
val splitWordArrays by cli.option(ArgType.Boolean, fullName = "splitarrays", description = "treat all word arrays as tagged with @split to make them lsb/msb split in memory")
val breakpointCpuInstruction by cli.option(ArgType.Boolean, fullName = "breakinstr", description = "also use a CPU instruction for %breakpoint")
val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}', '${AtariTarget.NAME}', '${PETTarget.NAME}', '${VMTarget.NAME}') (required)")
val startVm by cli.option(ArgType.Boolean, fullName = "vm", description = "load and run a .p8ir IR source file in the VM")
val watchMode by cli.option(ArgType.Boolean, fullName = "watch", description = "continuous compilation mode (watch for file changes)")
@ -122,6 +123,7 @@ private fun compileMain(args: Array<String>): Boolean {
varsHighBank,
compilationTarget!!,
splitWordArrays == true,
breakpointCpuInstruction = false,
processedSymbols,
srcdirs,
outputPath
@ -190,6 +192,7 @@ private fun compileMain(args: Array<String>): Boolean {
varsHighBank,
compilationTarget!!,
splitWordArrays == true,
breakpointCpuInstruction == true,
processedSymbols,
srcdirs,
outputPath

View File

@ -5,11 +5,11 @@ package prog8.buildversion
*/
const val MAVEN_GROUP = "prog8"
const val MAVEN_NAME = "compiler"
const val VERSION = "9.5-SNAPSHOT"
const val GIT_REVISION = 4108
const val GIT_SHA = "c319233ddc7f43a05e2090e293abbed8d80ce8cf"
const val GIT_DATE = "2023-09-18T21:22:03Z"
const val VERSION = "9.5"
const val GIT_REVISION = 4149
const val GIT_SHA = "203ec5fa46f883885b7e66526f18770aa1717785"
const val GIT_DATE = "2023-10-15T18:24:48Z"
const val GIT_BRANCH = "master"
const val BUILD_DATE = "2023-09-18T21:27:55Z"
const val BUILD_UNIX_TIME = 1695072475414L
const val BUILD_DATE = "2023-10-15T19:52:30Z"
const val BUILD_UNIX_TIME = 1697399550365L
const val DIRTY = 1

View File

@ -38,6 +38,7 @@ class CompilerArguments(val filepath: Path,
val varsHighBank: Int?,
val compilationTarget: String,
val splitWordArrays: Boolean,
val breakpointCpuInstruction: Boolean,
val symbolDefs: Map<String, String>,
val sourceDirs: List<String> = emptyList(),
val outputDir: Path = Path(""),
@ -74,6 +75,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
asmListfile = args.asmListfile
includeSourcelines = args.includeSourcelines
experimentalCodegen = args.experimentalCodegen
breakpointCpuInstruction = args.breakpointCpuInstruction
varsHighBank = args.varsHighBank
splitWordArrays = args.splitWordArrays
outputDir = args.outputDir.normalize()

View File

@ -35,6 +35,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
varsHighBank = null,
compilationTarget = target.name,
splitWordArrays = false,
breakpointCpuInstruction = false,
symbolDefs = emptyMap(),
outputDir = outputDir
)

View File

@ -52,6 +52,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
varsHighBank = null,
compilationTarget = Cx16Target.NAME,
splitWordArrays = false,
breakpointCpuInstruction = false,
symbolDefs = emptyMap(),
sourceDirs,
outputDir

View File

@ -34,7 +34,8 @@ internal fun compileFile(
symbolDefs = emptyMap(),
outputDir = outputDir,
errors = errors ?: ErrorReporterForTests(),
splitWordArrays = false
splitWordArrays = false,
breakpointCpuInstruction = false
)
return compileProgram(args)
}

View File

@ -166,6 +166,13 @@ One or more .p8 module files
``-asmlist``
Generate an assembler listing file as well.
``-breakinstr``
Also output a CPU instruction for a ``%breakpoint``, as well as the entry in the vice monitor list file.
This can be useful on emulators/systems that don't parse the breakpoint information in the list file,
such as the X16Emu emulator for the Commander X16. Prog8 then uses a STP instruction (65c02) to trigger a
breakpoint in the debugger (if enabled with -debug on the emulator). On a 6502 CPU, this option
will output a BRK instruction instead.
``-expericodegen``
Use experimental code generation backend (*incomplete*).

View File

@ -27,6 +27,7 @@ main {
txt.spc()
txt.print_uwhex(ptr, true)
txt.nl()
%breakpoint
ptr = &split_array
txt.print_uw(peekw(ptr))
txt.nl()

View File

@ -42,6 +42,7 @@ class RequestParser : Take {
asmListfile = false,
experimentalCodegen = false,
splitWordArrays = false,
breakpointCpuInstruction = false,
varsHighBank = null,
)
compileProgram(args)