fix bug in uword > comparison

This commit is contained in:
Irmen de Jong 2021-03-18 02:21:21 +01:00
parent b30b8b7368
commit 6780d4f562

View File

@ -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) { private fun translateUwordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
// TODO verify correctness uword >
fun code(msbCpyOperand: String, lsbCmpOperand: String) { fun code(msbCpyOperand: String, lsbCmpOperand: String) {
asmgen.out(""" asmgen.out("""
cpy $msbCpyOperand cpy $msbCpyOperand
bcs $jumpIfFalseLabel bcc $jumpIfFalseLabel
bne + bne +
cmp $lsbCmpOperand cmp $lsbCmpOperand
bcs $jumpIfFalseLabel bcc $jumpIfFalseLabel
+""") + beq $jumpIfFalseLabel
""")
} }
if(rightConstVal!=null) { if(rightConstVal!=null) {
@ -662,8 +661,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
return code("$varname+1", varname) return code("$varname+1", varname)
} }
asmgen.assignExpressionToVariable(left, "P8ZP_SCRATCH_W2", DataType.UWORD, null) asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_W2", DataType.UWORD, null)
asmgen.assignExpressionToRegister(right, RegisterOrPair.AY) asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
return code("P8ZP_SCRATCH_W2+1", "P8ZP_SCRATCH_W2") return code("P8ZP_SCRATCH_W2+1", "P8ZP_SCRATCH_W2")
} }