mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +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) {
|
if(choice.isElse) {
|
||||||
result += translateNode(choice.statements)
|
result += translateNode(choice.statements)
|
||||||
addInstr(result, IRInstruction(Opcode.JUMP, labelSymbol = endLabel), null)
|
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 {
|
} else {
|
||||||
val choiceLabel = createLabelName()
|
val choiceLabel = createLabelName()
|
||||||
choices.add(choiceLabel to choice)
|
choices.add(choiceLabel to choice)
|
||||||
@ -417,6 +423,7 @@ class IRCodeGen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
addInstr(result, IRInstruction(Opcode.JUMP, labelSymbol = endLabel), null)
|
addInstr(result, IRInstruction(Opcode.JUMP, labelSymbol = endLabel), null)
|
||||||
|
|
||||||
choices.forEach { (label, choice) ->
|
choices.forEach { (label, choice) ->
|
||||||
|
@ -419,17 +419,17 @@ _done
|
|||||||
}
|
}
|
||||||
|
|
||||||
word @zp d = 0
|
word @zp d = 0
|
||||||
cx16.r13 = true ; 'positive_ix'
|
cx16.r1L = true ; 'positive_ix'
|
||||||
if dx < 0 {
|
if dx < 0 {
|
||||||
dx = -dx
|
dx = -dx
|
||||||
cx16.r13 = false
|
cx16.r1L = false
|
||||||
}
|
}
|
||||||
word @zp dx2 = dx*2
|
word @zp dx2 = dx*2
|
||||||
word @zp dy2 = dy*2
|
word @zp dy2 = dy*2
|
||||||
cx16.r14 = x1 ; internal plot X
|
cx16.r14 = x1 ; internal plot X
|
||||||
|
|
||||||
if dx >= dy {
|
if dx >= dy {
|
||||||
if cx16.r13 {
|
if cx16.r1L {
|
||||||
repeat {
|
repeat {
|
||||||
plot(cx16.r14, y1, color)
|
plot(cx16.r14, y1, color)
|
||||||
if cx16.r14==x2
|
if cx16.r14==x2
|
||||||
@ -456,7 +456,7 @@ _done
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if cx16.r13 {
|
if cx16.r1L {
|
||||||
repeat {
|
repeat {
|
||||||
plot(cx16.r14, y1, color)
|
plot(cx16.r14, y1, color)
|
||||||
if y1 == y2
|
if y1 == y2
|
||||||
|
@ -262,15 +262,5 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
|
|||||||
}
|
}
|
||||||
return noModifications
|
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
|
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 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!
|
- 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
|
%import textio
|
||||||
%zeropage dontuse
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword pointer = $4000
|
ubyte var = 0
|
||||||
ubyte index = $e3
|
|
||||||
@($40e2) = 69
|
|
||||||
; cx16.r0L = pointer[index-1]
|
|
||||||
|
|
||||||
;cx16.r0L=69
|
when var {
|
||||||
;pointer[16] = cx16.r0L
|
1 -> txt.print("one")
|
||||||
ubyte targetindex=16
|
2 -> txt.print("two")
|
||||||
pointer[targetindex] = pointer[index-1]
|
0 -> {
|
||||||
pointer[16] = pointer[index-1]
|
}
|
||||||
txt.print_ub(@($4010)) ; expected: 69
|
else -> txt.print("other")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,4 @@ org.gradle.daemon=true
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
javaVersion=11
|
javaVersion=11
|
||||||
kotlinVersion=1.9.0
|
kotlinVersion=1.9.0
|
||||||
version=9.2
|
version=9.3-SNAPSHOT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user