From 64ea72ed4dae36467117058b67ac224b7f625379 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 1 Nov 2024 21:11:50 +0100 Subject: [PATCH] tweak plot --- .../codegen/intermediate/AssignmentGen.kt | 21 +++++++++---------- compiler/res/prog8lib/c64/graphics.p8 | 7 +++---- .../src/prog8/ast/statements/AstStatements.kt | 5 +---- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt index b66e81f93..4a4709a34 100644 --- a/codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt +++ b/codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt @@ -278,7 +278,6 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express } } "not" -> { - // TODO: in boolean branch, is 'not' handled ok like this? val register = codeGen.registers.nextFree() if(constIndex!=null) { result += IRCodeChunk(null, null).also { @@ -884,7 +883,7 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express } private fun operatorMultiplyInplaceSplitArray(array: PtArrayIndexer, operand: PtExpression): IRCodeChunks? { - return null // TODO("inplace split word array *") + return null // TODO("inplace split word array *") } private fun operatorMinusInplaceSplitArray(array: PtArrayIndexer, operand: PtExpression): IRCodeChunks? { @@ -1371,7 +1370,7 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express private fun createInplaceArrayComparison(array: PtArrayIndexer, value: PtExpression, comparisonOperator: String): IRCodeChunks? { if(array.type==DataType.FLOAT) - return null // TODO("optimized in-place compare on float arrays")) // TODO? + return null // TODO("optimized in-place compare on float arrays")) val eltSize = codeGen.program.memsizer.memorySize(array.type) val result = mutableListOf() @@ -1390,10 +1389,10 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express it += when(comparisonOperator) { "==" -> IRInstruction(Opcode.SZ, vmDt, reg1=cmpResultReg, reg2=valueReg) "!=" -> IRInstruction(Opcode.SNZ, vmDt, reg1=cmpResultReg, reg2=valueReg) - "<" -> return null // TODO("array <0 inplace")) // TODO? - "<=" -> return null // TODO("array <=0 inplace")) // TODO? - ">" -> return null // TODO("array >0 inplace")) // TODO? - ">=" -> return null // TODO("array >=0 inplace")) // TODO? + "<" -> return null // TODO("array <0 inplace")) + "<=" -> return null // TODO("array <=0 inplace")) + ">" -> return null // TODO("array >0 inplace")) + ">=" -> return null // TODO("array >=0 inplace")) else -> throw AssemblyError("invalid operator") } it += IRInstruction(Opcode.STOREM, vmDt, reg1 = cmpResultReg, labelSymbol = array.variable.name, symbolOffset = constIndex*eltSize) @@ -1413,10 +1412,10 @@ internal class AssignmentGen(private val codeGen: IRCodeGen, private val express it += when(comparisonOperator) { "==" -> IRInstruction(Opcode.SZ, vmDt, reg1=cmpResultReg, reg2=valueReg) "!=" -> IRInstruction(Opcode.SNZ, vmDt, reg1=cmpResultReg, reg2=valueReg) - "<" -> return null // TODO("array <0 inplace")) // TODO? - "<=" -> return null // TODO("array <=0 inplace")) // TODO? - ">" -> return null // TODO("array >0 inplace")) // TODO? - ">=" -> return null // TODO("array >=0 inplace")) // TODO? + "<" -> return null // TODO("array <0 inplace")) + "<=" -> return null // TODO("array <=0 inplace")) + ">" -> return null // TODO("array >0 inplace")) + ">=" -> return null // TODO("array >=0 inplace")) else -> throw AssemblyError("invalid operator") } it += IRInstruction(Opcode.STOREX, vmDt, reg1=valueReg, reg2=indexTr.resultReg, labelSymbol = array.variable.name) diff --git a/compiler/res/prog8lib/c64/graphics.p8 b/compiler/res/prog8lib/c64/graphics.p8 index 8507c4779..183358f84 100644 --- a/compiler/res/prog8lib/c64/graphics.p8 +++ b/compiler/res/prog8lib/c64/graphics.p8 @@ -347,12 +347,11 @@ hline_zero2 uword @zp internal_plotx ; 0..319 ; separate 'parameter' for internal_plot() - asmsub internal_plot(ubyte ploty @A) clobbers (A, X, Y) { ; internal_plotx is 16 bits 0 to 319... doesn't fit in a register + asmsub internal_plot(ubyte ploty @Y) clobbers (A, X, Y) { ; internal_plotx is 16 bits 0 to 319... doesn't fit in a register %asm {{ - tay lda p8v_internal_plotx+1 sta P8ZP_SCRATCH_W2+1 - lsr a ; 0 + lsr a ; make a=0 sta P8ZP_SCRATCH_W2 lda p8v_internal_plotx pha @@ -377,7 +376,7 @@ hline_zero2 _ormask .byte 128, 64, 32, 16, 8, 4, 2, 1 -; note: this can be even faster if we also have a 256 byte x-lookup table, but hey. +; note: this can be even faster if we also have a 320 word x-lookup table, but hey, that's a lot of memory. ; see http://codebase64.org/doku.php?id=base:various_techniques_to_calculate_adresses_fast_common_screen_formats_for_pixel_graphics ; the y lookup tables encodes this formula: BITMAP_ADDRESS + 320*(py>>3) + (py & 7) (y from 0..199) ; We use the 64tass syntax for range expressions to calculate this table on assembly time. diff --git a/compilerAst/src/prog8/ast/statements/AstStatements.kt b/compilerAst/src/prog8/ast/statements/AstStatements.kt index 279d39ee5..292493237 100644 --- a/compilerAst/src/prog8/ast/statements/AstStatements.kt +++ b/compilerAst/src/prog8/ast/statements/AstStatements.kt @@ -767,10 +767,7 @@ class Defer(val scope: AnonymousScope, override val position: Position): Stateme scope.linkParents(this) } - override fun replaceChildNode(node: Node, replacement: Node) { - TODO("Not yet implemented") - } - + override fun replaceChildNode(node: Node, replacement: Node) = throw FatalAstException("can't replace here") override fun referencesIdentifier(nameInSource: List): Boolean = scope.referencesIdentifier(nameInSource) override fun copy() = Defer(scope.copy(), position) override fun accept(visitor: IAstVisitor) = visitor.visit(this)