From 6780d4f562ca63af6cfe92bf3bb0dd1c6ded1e86 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 18 Mar 2021 02:21:21 +0100 Subject: [PATCH] fix bug in uword > comparison --- .../target/cpu6502/codegen/ExpressionsAsmGen.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt index 6e71b82a2..6eec294d9 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt @@ -622,16 +622,15 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge private fun translateUwordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { - // TODO verify correctness uword > - fun code(msbCpyOperand: String, lsbCmpOperand: String) { asmgen.out(""" cpy $msbCpyOperand - bcs $jumpIfFalseLabel + bcc $jumpIfFalseLabel bne + cmp $lsbCmpOperand - bcs $jumpIfFalseLabel -+""") + bcc $jumpIfFalseLabel ++ beq $jumpIfFalseLabel +""") } if(rightConstVal!=null) { @@ -662,8 +661,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge return code("$varname+1", varname) } - asmgen.assignExpressionToVariable(left, "P8ZP_SCRATCH_W2", DataType.UWORD, null) - asmgen.assignExpressionToRegister(right, RegisterOrPair.AY) + asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_W2", DataType.UWORD, null) + asmgen.assignExpressionToRegister(left, RegisterOrPair.AY) return code("P8ZP_SCRATCH_W2+1", "P8ZP_SCRATCH_W2") }