mirror of
https://github.com/irmen/prog8.git
synced 2024-11-25 19:31:36 +00:00
Merge branch 'master' into remove_evalstack
# Conflicts: # examples/test.p8
This commit is contained in:
commit
a0ab0bd3e2
@ -409,6 +409,12 @@ class IRCodeGen(
|
||||
if(choice.isElse) {
|
||||
result += translateNode(choice.statements)
|
||||
addInstr(result, IRInstruction(Opcode.JUMP, labelSymbol = endLabel), null)
|
||||
} else {
|
||||
if(choice.statements.children.isEmpty()) {
|
||||
// no statements for this choice value, jump to the end immediately
|
||||
choice.values.children.map { it as PtNumber }.sortedBy { it.number }.forEach { value ->
|
||||
addInstr(result, IRInstruction(Opcode.BEQ, valueDt, reg1=valueTr.resultReg, immediate = value.number.toInt(), labelSymbol = endLabel), null)
|
||||
}
|
||||
} else {
|
||||
val choiceLabel = createLabelName()
|
||||
choices.add(choiceLabel to choice)
|
||||
@ -417,6 +423,7 @@ class IRCodeGen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
addInstr(result, IRInstruction(Opcode.JUMP, labelSymbol = endLabel), null)
|
||||
|
||||
choices.forEach { (label, choice) ->
|
||||
|
@ -419,17 +419,17 @@ _done
|
||||
}
|
||||
|
||||
word @zp d = 0
|
||||
cx16.r13 = true ; 'positive_ix'
|
||||
cx16.r1L = true ; 'positive_ix'
|
||||
if dx < 0 {
|
||||
dx = -dx
|
||||
cx16.r13 = false
|
||||
cx16.r1L = false
|
||||
}
|
||||
word @zp dx2 = dx*2
|
||||
word @zp dy2 = dy*2
|
||||
cx16.r14 = x1 ; internal plot X
|
||||
|
||||
if dx >= dy {
|
||||
if cx16.r13 {
|
||||
if cx16.r1L {
|
||||
repeat {
|
||||
plot(cx16.r14, y1, color)
|
||||
if cx16.r14==x2
|
||||
@ -456,7 +456,7 @@ _done
|
||||
}
|
||||
}
|
||||
else {
|
||||
if cx16.r13 {
|
||||
if cx16.r1L {
|
||||
repeat {
|
||||
plot(cx16.r14, y1, color)
|
||||
if y1 == y2
|
||||
|
@ -262,15 +262,5 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
|
||||
}
|
||||
return noModifications
|
||||
}
|
||||
|
||||
override fun after(whenStmt: When, parent: Node): Iterable<IAstModification> {
|
||||
val removals = mutableListOf<Int>()
|
||||
whenStmt.choices.withIndex().forEach { (index, choice) ->
|
||||
if(choice.statements.isEmpty())
|
||||
removals.add(index)
|
||||
}
|
||||
removals.reversed().forEach { whenStmt.choices.removeAt(it) }
|
||||
return noModifications
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- compiling Rockrunner with -noopt crashes the program soon after startup
|
||||
|
||||
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
||||
|
||||
|
@ -1,18 +1,16 @@
|
||||
%import textio
|
||||
%zeropage dontuse
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword pointer = $4000
|
||||
ubyte index = $e3
|
||||
@($40e2) = 69
|
||||
; cx16.r0L = pointer[index-1]
|
||||
ubyte var = 0
|
||||
|
||||
;cx16.r0L=69
|
||||
;pointer[16] = cx16.r0L
|
||||
ubyte targetindex=16
|
||||
pointer[targetindex] = pointer[index-1]
|
||||
pointer[16] = pointer[index-1]
|
||||
txt.print_ub(@($4010)) ; expected: 69
|
||||
when var {
|
||||
1 -> txt.print("one")
|
||||
2 -> txt.print("two")
|
||||
0 -> {
|
||||
}
|
||||
else -> txt.print("other")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,4 @@ org.gradle.daemon=true
|
||||
kotlin.code.style=official
|
||||
javaVersion=11
|
||||
kotlinVersion=1.9.0
|
||||
version=9.2
|
||||
version=9.3-SNAPSHOT
|
||||
|
Loading…
Reference in New Issue
Block a user