mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +00:00
changed -breakinstr option so that you now specify the exact instruction to use for a %breakpoint.
also fixed a IR issue with x=not x.
This commit is contained in:
parent
84a7e86fe3
commit
64c132ee0a
@ -25,7 +25,7 @@ class CompilationOptions(val output: OutputType,
|
|||||||
var slabsHighBank: Int? = null,
|
var slabsHighBank: Int? = null,
|
||||||
var slabsGolden: Boolean = false,
|
var slabsGolden: Boolean = false,
|
||||||
var splitWordArrays: Boolean = false,
|
var splitWordArrays: Boolean = false,
|
||||||
var breakpointCpuInstruction: Boolean = false,
|
var breakpointCpuInstruction: String? = null,
|
||||||
var outputDir: Path = Path(""),
|
var outputDir: Path = Path(""),
|
||||||
var symbolDefs: Map<String, String> = emptyMap()
|
var symbolDefs: Map<String, String> = emptyMap()
|
||||||
) {
|
) {
|
||||||
|
@ -1102,14 +1102,8 @@ $repeatLabel""")
|
|||||||
val label = "_prog8_breakpoint_${breakpointLabels.size+1}"
|
val label = "_prog8_breakpoint_${breakpointLabels.size+1}"
|
||||||
breakpointLabels.add(label)
|
breakpointLabels.add(label)
|
||||||
out(label)
|
out(label)
|
||||||
if(options.breakpointCpuInstruction) {
|
if(options.breakpointCpuInstruction!=null) {
|
||||||
val instruction =
|
out(" ${options.breakpointCpuInstruction}")
|
||||||
when(options.compTarget.machine.cpu) {
|
|
||||||
CpuType.CPU6502 -> "brk"
|
|
||||||
CpuType.CPU65c02 -> "stp"
|
|
||||||
else -> throw AssemblyError("invalid cpu type")
|
|
||||||
}
|
|
||||||
out(" $instruction")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,8 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express
|
|||||||
value.add(origAssign.value)
|
value.add(origAssign.value)
|
||||||
} else {
|
} else {
|
||||||
require(origAssign.operator.endsWith('='))
|
require(origAssign.operator.endsWith('='))
|
||||||
value = PtBinaryExpression(origAssign.operator.dropLast(1), origAssign.target.type, origAssign.value.position)
|
val operator = if(origAssign.operator=="==") "==" else origAssign.operator.dropLast(1)
|
||||||
|
value = PtBinaryExpression(operator, origAssign.target.type, origAssign.value.position)
|
||||||
val left: PtExpression = origAssign.target.children.single() as PtExpression
|
val left: PtExpression = origAssign.target.children.single() as PtExpression
|
||||||
value.add(left)
|
value.add(left)
|
||||||
value.add(origAssign.value)
|
value.add(origAssign.value)
|
||||||
|
@ -52,7 +52,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
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 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 printAst1 by cli.option(ArgType.Boolean, fullName = "printast1", description = "print out the compiler AST")
|
val printAst1 by cli.option(ArgType.Boolean, fullName = "printast1", description = "print out the compiler AST")
|
||||||
val printAst2 by cli.option(ArgType.Boolean, fullName = "printast2", description = "print out the intermediate AST that is used for code generation")
|
val printAst2 by cli.option(ArgType.Boolean, fullName = "printast2", description = "print out the intermediate AST that is used for code generation")
|
||||||
val breakpointCpuInstruction by cli.option(ArgType.Boolean, fullName = "breakinstr", description = "also use a CPU instruction for %breakpoint")
|
val breakpointCpuInstruction by cli.option(ArgType.Choice(listOf("brk", "stp"), { it }), fullName = "breakinstr", description = "the CPU instruction to use as well 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 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 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)")
|
val watchMode by cli.option(ArgType.Boolean, fullName = "watch", description = "continuous compilation mode (watch for file changes)")
|
||||||
@ -69,6 +69,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("BREAKPOINTINSTR=$breakpointCpuInstruction")
|
||||||
|
|
||||||
val outputPath = pathFrom(outputDir)
|
val outputPath = pathFrom(outputDir)
|
||||||
if(!outputPath.toFile().isDirectory) {
|
if(!outputPath.toFile().isDirectory) {
|
||||||
System.err.println("Output path doesn't exist")
|
System.err.println("Output path doesn't exist")
|
||||||
@ -158,7 +160,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
slabsGolden == true,
|
slabsGolden == true,
|
||||||
compilationTarget!!,
|
compilationTarget!!,
|
||||||
splitWordArrays == true,
|
splitWordArrays == true,
|
||||||
breakpointCpuInstruction = false,
|
breakpointCpuInstruction,
|
||||||
printAst1 == true,
|
printAst1 == true,
|
||||||
printAst2 == true,
|
printAst2 == true,
|
||||||
processedSymbols,
|
processedSymbols,
|
||||||
@ -236,7 +238,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
slabsGolden == true,
|
slabsGolden == true,
|
||||||
compilationTarget!!,
|
compilationTarget!!,
|
||||||
splitWordArrays == true,
|
splitWordArrays == true,
|
||||||
breakpointCpuInstruction == true,
|
breakpointCpuInstruction,
|
||||||
printAst1 == true,
|
printAst1 == true,
|
||||||
printAst2 == true,
|
printAst2 == true,
|
||||||
processedSymbols,
|
processedSymbols,
|
||||||
|
@ -44,7 +44,7 @@ class CompilerArguments(val filepath: Path,
|
|||||||
val slabsGolden: Boolean,
|
val slabsGolden: Boolean,
|
||||||
val compilationTarget: String,
|
val compilationTarget: String,
|
||||||
val splitWordArrays: Boolean,
|
val splitWordArrays: Boolean,
|
||||||
val breakpointCpuInstruction: Boolean,
|
val breakpointCpuInstruction: String?,
|
||||||
val printAst1: Boolean,
|
val printAst1: Boolean,
|
||||||
val printAst2: Boolean,
|
val printAst2: Boolean,
|
||||||
val symbolDefs: Map<String, String>,
|
val symbolDefs: Map<String, String>,
|
||||||
|
@ -38,7 +38,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
|||||||
slabsGolden = false,
|
slabsGolden = false,
|
||||||
compilationTarget = target.name,
|
compilationTarget = target.name,
|
||||||
splitWordArrays = false,
|
splitWordArrays = false,
|
||||||
breakpointCpuInstruction = false,
|
breakpointCpuInstruction = null,
|
||||||
printAst1 = false,
|
printAst1 = false,
|
||||||
printAst2 = false,
|
printAst2 = false,
|
||||||
symbolDefs = emptyMap(),
|
symbolDefs = emptyMap(),
|
||||||
|
@ -36,7 +36,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
|||||||
slabsGolden = false,
|
slabsGolden = false,
|
||||||
compilationTarget = Cx16Target.NAME,
|
compilationTarget = Cx16Target.NAME,
|
||||||
splitWordArrays = false,
|
splitWordArrays = false,
|
||||||
breakpointCpuInstruction = false,
|
breakpointCpuInstruction = null,
|
||||||
printAst1 = false,
|
printAst1 = false,
|
||||||
printAst2 = false,
|
printAst2 = false,
|
||||||
symbolDefs = emptyMap(),
|
symbolDefs = emptyMap(),
|
||||||
|
@ -38,7 +38,7 @@ internal fun compileFile(
|
|||||||
outputDir = outputDir,
|
outputDir = outputDir,
|
||||||
errors = errors ?: ErrorReporterForTests(),
|
errors = errors ?: ErrorReporterForTests(),
|
||||||
splitWordArrays = false,
|
splitWordArrays = false,
|
||||||
breakpointCpuInstruction = false,
|
breakpointCpuInstruction = null,
|
||||||
printAst1 = false,
|
printAst1 = false,
|
||||||
printAst2 = false
|
printAst2 = false
|
||||||
)
|
)
|
||||||
|
@ -175,12 +175,13 @@ One or more .p8 module files
|
|||||||
``-check``
|
``-check``
|
||||||
Quickly check the program for errors. No output will be produced.
|
Quickly check the program for errors. No output will be produced.
|
||||||
|
|
||||||
``-breakinstr``
|
``-breakinstr <instruction>``
|
||||||
Also output a CPU instruction for a ``%breakpoint``, as well as the entry in the vice monitor list file.
|
Also output the specified 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,
|
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
|
such as the X16Emu emulator for the Commander X16.
|
||||||
breakpoint in the debugger (if enabled with -debug on the emulator). On a 6502 CPU, this option
|
Useful instructions to consider are ``brk`` and ``stp``.
|
||||||
will output a BRK instruction instead.
|
For example for the Commander X16 emulator, ``stp`` is useful because it can actually tyrigger
|
||||||
|
a breakpoint halt in the debugger when this is enabled by running the emulator with -debug.
|
||||||
|
|
||||||
``-expericodegen``
|
``-expericodegen``
|
||||||
Use experimental code generation backend (*incomplete*).
|
Use experimental code generation backend (*incomplete*).
|
||||||
|
@ -4,8 +4,6 @@ TODO
|
|||||||
maze: if cell & UP!=0 and @(celladdr(cx,cy-1)) & (WALKED|BACKTRACKED) ==0
|
maze: if cell & UP!=0 and @(celladdr(cx,cy-1)) & (WALKED|BACKTRACKED) ==0
|
||||||
^^ adding this !=0 caused a weird beq + / lda #1 / + to appear in front of the shortcircuit beq...
|
^^ adding this !=0 caused a weird beq + / lda #1 / + to appear in front of the shortcircuit beq...
|
||||||
|
|
||||||
make the breakpoint instruction selectable (BRK vs STP)
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,30 +1,15 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage dontuse
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
const uword one = 1
|
ubyte @shared ubb = 99
|
||||||
const uword two = 2
|
uword @shared uww = 12345
|
||||||
uword @shared answer = one * two >> 8
|
ubyte[200] @shared barr
|
||||||
txt.print_uw(answer)
|
uword @shared ptr = memory("data", $2000, 0)
|
||||||
txt.spc()
|
|
||||||
txt.print_uw(one * two >> 8)
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
const uword uw1 = 99
|
%breakpoint
|
||||||
const uword uw2 = 22
|
|
||||||
uword @shared answer2 = uw1 * uw2 >> 8
|
|
||||||
txt.print_uw(answer2)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_uw(uw1 * uw2 >> 8)
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
uword @shared uw3 = 99
|
txt.print_uwhex(sys.progend(), true)
|
||||||
uword @shared uw4 = 22
|
|
||||||
uword @shared answer3 = uw3 * uw4 >> 8
|
|
||||||
txt.print_uw(answer3)
|
|
||||||
txt.spc()
|
|
||||||
txt.print_uw(uw3 * uw4 >> 8)
|
|
||||||
txt.nl()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class RequestParser : Take {
|
|||||||
asmListfile = false,
|
asmListfile = false,
|
||||||
experimentalCodegen = false,
|
experimentalCodegen = false,
|
||||||
splitWordArrays = false,
|
splitWordArrays = false,
|
||||||
breakpointCpuInstruction = false,
|
breakpointCpuInstruction = null,
|
||||||
printAst1 = false,
|
printAst1 = false,
|
||||||
printAst2 = false,
|
printAst2 = false,
|
||||||
varsHighBank = null,
|
varsHighBank = null,
|
||||||
|
Loading…
Reference in New Issue
Block a user