mirror of
https://github.com/irmen/prog8.git
synced 2024-08-10 14:29:06 +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 slabsGolden: Boolean = false,
|
||||
var splitWordArrays: Boolean = false,
|
||||
var breakpointCpuInstruction: Boolean = false,
|
||||
var breakpointCpuInstruction: String? = null,
|
||||
var outputDir: Path = Path(""),
|
||||
var symbolDefs: Map<String, String> = emptyMap()
|
||||
) {
|
||||
|
@ -1102,14 +1102,8 @@ $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")
|
||||
if(options.breakpointCpuInstruction!=null) {
|
||||
out(" ${options.breakpointCpuInstruction}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,8 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express
|
||||
value.add(origAssign.value)
|
||||
} else {
|
||||
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
|
||||
value.add(left)
|
||||
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 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 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 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)")
|
||||
@ -69,6 +69,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
println("BREAKPOINTINSTR=$breakpointCpuInstruction")
|
||||
|
||||
val outputPath = pathFrom(outputDir)
|
||||
if(!outputPath.toFile().isDirectory) {
|
||||
System.err.println("Output path doesn't exist")
|
||||
@ -158,7 +160,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
slabsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction = false,
|
||||
breakpointCpuInstruction,
|
||||
printAst1 == true,
|
||||
printAst2 == true,
|
||||
processedSymbols,
|
||||
@ -236,7 +238,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
slabsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction == true,
|
||||
breakpointCpuInstruction,
|
||||
printAst1 == true,
|
||||
printAst2 == true,
|
||||
processedSymbols,
|
||||
|
@ -44,7 +44,7 @@ class CompilerArguments(val filepath: Path,
|
||||
val slabsGolden: Boolean,
|
||||
val compilationTarget: String,
|
||||
val splitWordArrays: Boolean,
|
||||
val breakpointCpuInstruction: Boolean,
|
||||
val breakpointCpuInstruction: String?,
|
||||
val printAst1: Boolean,
|
||||
val printAst2: Boolean,
|
||||
val symbolDefs: Map<String, String>,
|
||||
|
@ -38,7 +38,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
||||
slabsGolden = false,
|
||||
compilationTarget = target.name,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
breakpointCpuInstruction = null,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
symbolDefs = emptyMap(),
|
||||
|
@ -36,7 +36,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
||||
slabsGolden = false,
|
||||
compilationTarget = Cx16Target.NAME,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
breakpointCpuInstruction = null,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
symbolDefs = emptyMap(),
|
||||
|
@ -38,7 +38,7 @@ internal fun compileFile(
|
||||
outputDir = outputDir,
|
||||
errors = errors ?: ErrorReporterForTests(),
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
breakpointCpuInstruction = null,
|
||||
printAst1 = false,
|
||||
printAst2 = false
|
||||
)
|
||||
|
@ -175,12 +175,13 @@ One or more .p8 module files
|
||||
``-check``
|
||||
Quickly check the program for errors. No output will be produced.
|
||||
|
||||
``-breakinstr``
|
||||
Also output a CPU instruction for a ``%breakpoint``, as well as the entry in the vice monitor list file.
|
||||
``-breakinstr <instruction>``
|
||||
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,
|
||||
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.
|
||||
such as the X16Emu emulator for the Commander X16.
|
||||
Useful instructions to consider are ``brk`` and ``stp``.
|
||||
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``
|
||||
Use experimental code generation backend (*incomplete*).
|
||||
|
@ -4,8 +4,6 @@ TODO
|
||||
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...
|
||||
|
||||
make the breakpoint instruction selectable (BRK vs STP)
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -1,30 +1,15 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
%zeropage dontuse
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
const uword one = 1
|
||||
const uword two = 2
|
||||
uword @shared answer = one * two >> 8
|
||||
txt.print_uw(answer)
|
||||
txt.spc()
|
||||
txt.print_uw(one * two >> 8)
|
||||
txt.nl()
|
||||
ubyte @shared ubb = 99
|
||||
uword @shared uww = 12345
|
||||
ubyte[200] @shared barr
|
||||
uword @shared ptr = memory("data", $2000, 0)
|
||||
|
||||
const uword uw1 = 99
|
||||
const uword uw2 = 22
|
||||
uword @shared answer2 = uw1 * uw2 >> 8
|
||||
txt.print_uw(answer2)
|
||||
txt.spc()
|
||||
txt.print_uw(uw1 * uw2 >> 8)
|
||||
txt.nl()
|
||||
%breakpoint
|
||||
|
||||
uword @shared uw3 = 99
|
||||
uword @shared uw4 = 22
|
||||
uword @shared answer3 = uw3 * uw4 >> 8
|
||||
txt.print_uw(answer3)
|
||||
txt.spc()
|
||||
txt.print_uw(uw3 * uw4 >> 8)
|
||||
txt.nl()
|
||||
txt.print_uwhex(sys.progend(), true)
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class RequestParser : Take {
|
||||
asmListfile = false,
|
||||
experimentalCodegen = false,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
breakpointCpuInstruction = null,
|
||||
printAst1 = false,
|
||||
printAst2 = false,
|
||||
varsHighBank = null,
|
||||
|
Loading…
Reference in New Issue
Block a user