diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt index 2782c4a44..bddfeb706 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt @@ -838,17 +838,15 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge private fun translateWordLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { - // TODO fix this word <= - - fun code(msbCpyOperand: String, lsbCmpOperand: String) { + fun code(leftName: String) { asmgen.out(""" - cmp $msbCpyOperand + cmp $leftName tya - sbc $lsbCmpOperand + sbc $leftName+1 bvc + eor #$80 -+ bpl $jumpIfFalseLabel""" - ) ++ bmi $jumpIfFalseLabel +""") } if(rightConstVal!=null) { @@ -859,8 +857,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge } else { if (left is IdentifierReference) { return if(rightConstVal.number.toInt()!=0) { - asmgen.assignExpressionToRegister(left, RegisterOrPair.AY) - code("#>${rightConstVal.number}", "#<${rightConstVal.number}") + asmgen.assignExpressionToRegister(right, RegisterOrPair.AY) + code(asmgen.asmVariableName(left)) } else { val name = asmgen.asmVariableName(left) @@ -876,10 +874,9 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge } } - if(right is IdentifierReference) { - asmgen.assignExpressionToRegister(left, RegisterOrPair.AY) - val varname = asmgen.asmVariableName(right) - return code("$varname+1", varname) + if(left is IdentifierReference) { + asmgen.assignExpressionToRegister(right, RegisterOrPair.AY) + return code(asmgen.asmVariableName(left)) } asmgen.assignExpressionToVariable(left, "P8ZP_SCRATCH_W2", DataType.UWORD, null) @@ -998,8 +995,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge private fun translateWordGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { - // TODO fix this word >= - fun code(msbCpyOperand: String, lsbCmpOperand: String) { asmgen.out(""" cmp $lsbCmpOperand diff --git a/compiler/test/comparisons/old_cmps.p8 b/compiler/test/comparisons/old_cmps.p8 deleted file mode 100644 index ddeb91320..000000000 --- a/compiler/test/comparisons/old_cmps.p8 +++ /dev/null @@ -1,1008 +0,0 @@ -%import textio -%import floats -%zeropage basicsafe - -main { - - byte bb= -22 - ubyte ubb = 22 - word ww= -2222 - uword uww = 2222 - float ff = -2.2 - - sub start() { - - repeat(25) - txt.nl() - - equal() - txt.nl() - notequal() - txt.nl() - less() - txt.nl() - greater() - txt.nl() - lessequal() - txt.nl() - greaterequal() - txt.nl() - } - - sub equal() { - - if bb == -22 { - txt.print("ok == 1\n") - } else { - txt.print("fail == 1\n") - } - - if bb == -23 { - txt.print("fail == 2\n") - } else { - txt.print("ok == 2\n") - } - - if bb==0 { - txt.print("fail == 2b\n") - } else { - txt.print("ok == 2b\n") - } - - if ww == -2222 { - txt.print("ok == 3\n") - } else { - txt.print("fail == 3\n") - } - - if ww == -2223 { - txt.print("fail == 4\n") - } else { - txt.print("ok == 4\n") - } - - if ww == 0 { - txt.print("fail == 4a\n") - } else { - txt.print("ok == 4a\n") - } - - if ff == -2.2 { - txt.print("ok == 4c\n") - } else { - txt.print("fail == 4c\n") - } - - if ff == -2.3 { - txt.print("fail == 4d\n") - } else { - txt.print("ok == 4d\n") - } - - if ff == 0.0 { - txt.print("fail == 4e\n") - } else { - txt.print("ok == 4e\n") - } - - if ubb == 22 { - txt.print("ok == 4f\n") - } else { - txt.print("fail == 4f\n") - } - - if ubb == 23 { - txt.print("fail == 4g\n") - } else { - txt.print("ok == 4g\n") - } - - if ubb == 0 { - txt.print("fail == 4h\n") - } else { - txt.print("ok == 4h\n") - } - - if uww == 2222 { - txt.print("ok == 4i\n") - } else { - txt.print("fail == 4i\n") - } - - if uww == 2223 { - txt.print("fail == 4j\n") - } else { - txt.print("ok == 4j\n") - } - - if uww == 0 { - txt.print("fail == 4k\n") - } else { - txt.print("ok == 4k\n") - } - } - - sub notequal() { - - if bb != -23 { - txt.print("ok != 1\n") - } else { - txt.print("fail != 1\n") - } - - if bb != -22 { - txt.print("fail != 2\n") - } else { - txt.print("ok != 2\n") - } - - if bb!=0 { - txt.print("ok != 2b\n") - } else { - txt.print("fail != 2b\n") - } - - if ww != -2223 { - txt.print("ok != 3\n") - } else { - txt.print("fail != 3\n") - } - - if ww != -2222 { - txt.print("fail != 4\n") - } else { - txt.print("ok != 4\n") - } - - if ww != 0 { - txt.print("ok != 4a\n") - } else { - txt.print("fail != 4a\n") - } - - if ff != -2.3 { - txt.print("ok != 4c\n") - } else { - txt.print("fail != 4c\n") - } - - if ff != -2.2 { - txt.print("fail != 4d\n") - } else { - txt.print("ok != 4d\n") - } - - if ff != 0.0 { - txt.print("ok != 4e\n") - } else { - txt.print("fail != 4e\n") - } - - if ubb != 23 { - txt.print("ok != 4f\n") - } else { - txt.print("fail != 4f\n") - } - - if ubb != 22 { - txt.print("fail != 4g\n") - } else { - txt.print("ok != 4g\n") - } - - if ubb != 0 { - txt.print("ok != 4h\n") - } else { - txt.print("fail != 4h\n") - } - - if uww != 2223 { - txt.print("ok != 4i\n") - } else { - txt.print("fail != 4i\n") - } - - if uww != 2222 { - txt.print("fail != 4j\n") - } else { - txt.print("ok != 4j\n") - } - - if uww != 0 { - txt.print("ok != 4k\n") - } else { - txt.print("fail != 4k\n") - } - } - - sub less() { - - if bb < -1 { - txt.print("ok < 1\n") - } else { - txt.print("fail < 1\n") - } - - if bb < -99 { - txt.print("fail < 2\n") - } else { - txt.print("ok < 2\n") - } - - if bb < -22 { - txt.print("fail < 2a\n") - } else { - txt.print("ok < 2a\n") - } - - if bb<0 { - txt.print("ok < 2b\n") - } else { - txt.print("fail < 2b\n") - } - - if ww < -1 { - txt.print("ok < 3\n") - } else { - txt.print("fail < 3\n") - } - - if ww < -9999 { - txt.print("fail < 4\n") - } else { - txt.print("ok < 4\n") - } - - if ww < -2222 { - txt.print("fail < 4a\n") - } else { - txt.print("ok < 4a\n") - } - - if ww < 0 { - txt.print("ok < 4b\n") - } else { - txt.print("fail < 4b\n") - } - - if ff < -1.0 { - txt.print("ok < 4c\n") - } else { - txt.print("fail < 4c\n") - } - - if ff < -9999.9 { - txt.print("fail < 4d\n") - } else { - txt.print("ok < 4d\n") - } - - if ff < 0.0 { - txt.print("ok < 4e\n") - } else { - txt.print("fail < 4e\n") - } - - if ff < -2.2 { - txt.print("fail < 4e2\n") - } else { - txt.print("ok < 4e2\n") - } - - if ubb < 100 { - txt.print("ok < 4f\n") - } else { - txt.print("fail < 4f\n") - } - - if ubb < 2 { - txt.print("fail < 4g\n") - } else { - txt.print("ok < 4g\n") - } - - if ubb<0 { - txt.print("fail < 4h\n") - } else { - txt.print("ok < 4h\n") - } - - if ubb<22 { - txt.print("fail < 4h2\n") - } else { - txt.print("ok < 4h2\n") - } - - if uww < 10000 { - txt.print("ok < 4i\n") - } else { - txt.print("fail < 4i\n") - } - - if uww < 2 { - txt.print("fail < 4j\n") - } else { - txt.print("ok < 4j\n") - } - - if uww < 0 { - txt.print("fail < 4k\n") - } else { - txt.print("ok < 4k\n") - } - - if uww < 2222 { - txt.print("fail < 4l\n") - } else { - txt.print("ok < 4l\n") - } - - ; some more special cases for signed comparison - byte b2 = -100 - word w2 = -30000 - if b2 < -127 { - txt.print("fail < eb1\n") - } else { - txt.print("ok < eb1\n") - } - if b2 < -101 { - txt.print("fail < eb2\n") - } else { - txt.print("ok < eb2\n") - } - if b2 < -100 { - txt.print("fail < eb3\n") - } else { - txt.print("ok < eb3\n") - } - if b2 < -99 { - txt.print("ok < eb4\n") - } else { - txt.print("fail < eb4\n") - } - if b2 < 100 { - txt.print("ok < eb5\n") - } else { - txt.print("fail < eb5\n") - } - if b2 < 127 { - txt.print("ok < eb6\n") - } else { - txt.print("fail < eb6\n") - } - if b2 < 0 { - txt.print("ok < eb7\n") - } else { - txt.print("fail < eb7\n") - } - - if w2 < -32768 { - txt.print("fail < ew1\n") - } else { - txt.print("ok < ew1\n") - } - if w2 < -30001 { - txt.print("fail < ew2\n") - } else { - txt.print("ok < ew2\n") - } - if w2 < -30000 { - txt.print("fail < ew3\n") - } else { - txt.print("ok < ew3\n") - } - if w2 < -29999 { - txt.print("ok < ew4\n") - } else { - txt.print("fail < ew4\n") - } - if w2 < 30000 { - txt.print("ok < ew5\n") - } else { - txt.print("fail < ew5\n") - } - if w2 < 32767 { - txt.print("ok < ew6\n") - } else { - txt.print("fail < ew6\n") - } - if w2 < 0 { - txt.print("ok < ew7\n") - } else { - txt.print("fail < ew7\n") - } - } - - sub greater() { - if bb > -99 { - txt.print("ok > 5\n") - } else { - txt.print("fail > 5\n") - } - - if bb > -1 { - txt.print("fail > 6\n") - } else { - txt.print("ok > 6\n") - } - - if bb > 0 { - txt.print("fail > 6b\n") - } else { - txt.print("ok > 6b\n") - } - - if bb > -22 { - txt.print("fail > 6c\n") - } else { - txt.print("ok > 6c\n") - } - - if ww > -9999 { - txt.print("ok > 7\n") - } else { - txt.print("fail > 7\n") - } - - if ww > -1 { - txt.print("fail > 8\n") - } else { - txt.print("ok > 8\n") - } - - if ww>0 { - txt.print("fail > 8b\n") - } else { - txt.print("ok > 8b\n") - } - - if ww>-2222 { - txt.print("fail > 8b2\n") - } else { - txt.print("ok > 8b2\n") - } - - if ff > -1.0 { - txt.print("fail > 8c\n") - } else { - txt.print("ok > 8c\n") - } - - if ff > -9999.9 { - txt.print("ok > 8d\n") - } else { - txt.print("fail > 8d\n") - } - - if ff > 0.0 { - txt.print("fail > 8e\n") - } else { - txt.print("ok > 8e\n") - } - - if ff > -2.2 { - txt.print("fail > 8e2\n") - } else { - txt.print("ok > 8e2\n") - } - - if ubb > 5 { - txt.print("ok > 8f\n") - } else { - txt.print("fail > 8f\n") - } - - if ubb > 250 { - txt.print("fail > 8g\n") - } else { - txt.print("ok > 8g\n") - } - - if ubb > 0 { - txt.print("ok > 8h\n") - } else { - txt.print("fail > 8h\n") - } - - if ubb > 22 { - txt.print("fail > 8h2\n") - } else { - txt.print("ok > 8h2\n") - } - - if uww > 5 { - txt.print("ok > 8i\n") - } else { - txt.print("fail > 8i\n") - } - - if uww > 9999 { - txt.print("fail > 8j\n") - } else { - txt.print("ok > 8j\n") - } - - if uww>0 { - txt.print("ok > 8k\n") - } else { - txt.print("fail > 8k\n") - } - - if uww>2222 { - txt.print("fail > 8l\n") - } else { - txt.print("ok > 8l\n") - } - - ; some more special cases for signed comparison - byte b2 = -100 - word w2 = -30000 - if b2 > -127 { - txt.print("ok > eb1\n") - } else { - txt.print("fail > eb1\n") - } - if b2 > -101 { - txt.print("ok > eb2\n") - } else { - txt.print("fail > eb2\n") - } - if b2 > -100 { - txt.print("fail > eb3\n") - } else { - txt.print("ok > eb3\n") - } - if b2 > -99 { - txt.print("fail > eb4\n") - } else { - txt.print("ok > eb4\n") - } - if b2 > 100 { - txt.print("fail > eb5\n") - } else { - txt.print("ok > eb5\n") - } - if b2 > 127 { - txt.print("fail > eb6\n") - } else { - txt.print("ok > eb6\n") - } - if b2 > 0 { - txt.print("fail > eb7\n") - } else { - txt.print("ok > eb7\n") - } - - if w2 > -32768 { - txt.print("ok > ew1\n") - } else { - txt.print("fail > ew1\n") - } - if w2 > -30001 { - txt.print("ok > ew2\n") - } else { - txt.print("fail > ew2\n") - } - if w2 > -30000 { - txt.print("fail > ew3\n") - } else { - txt.print("ok > ew3\n") - } - if w2 > -29999 { - txt.print("fail > ew4\n") - } else { - txt.print("ok > ew4\n") - } - if w2 > 30000 { - txt.print("fail > ew5\n") - } else { - txt.print("ok > ew5\n") - } - if w2 > 32767 { - txt.print("fail > ew6\n") - } else { - txt.print("ok > ew6\n") - } - if w2 > 0 { - txt.print("fail > ew6\n") - } else { - txt.print("ok > ew6\n") - } - } - - sub lessequal() { - - if bb <= -1 { - txt.print("ok <= 1\n") - } else { - txt.print("fail <= 1\n") - } - - if bb <= -99 { - txt.print("fail <= 2\n") - } else { - txt.print("ok <= 2\n") - } - - if bb <= -22 { - txt.print("ok <= 2a\n") - } else { - txt.print("fail <= 2a\n") - } - - if bb<=0 { - txt.print("ok <= 2b\n") - } else { - txt.print("fail <= 2b\n") - } - - if ww <= -1 { - txt.print("ok <= 3\n") - } else { - txt.print("fail <= 3\n") - } - - if ww <= -9999 { - txt.print("fail <= 4\n") - } else { - txt.print("ok <= 4\n") - } - - if ww <= -2222 { - txt.print("ok <= 4a\n") - } else { - txt.print("fail <= 4a\n") - } - - if ww <= 0 { - txt.print("ok <= 4b\n") - } else { - txt.print("fail <= 4b\n") - } - - if ff <= -1.0 { - txt.print("ok <= 4c\n") - } else { - txt.print("fail <= 4c\n") - } - - if ff <= -9999.9 { - txt.print("fail <= 4d\n") - } else { - txt.print("ok <= 4d\n") - } - - if ff <= 0.0 { - txt.print("ok <= 4e\n") - } else { - txt.print("fail <= 4e\n") - } - - if ff <= -2.2 { - txt.print("ok <= 4e2\n") - } else { - txt.print("fail <= 4e2\n") - } - - if ubb <= 100 { - txt.print("ok <= 4f\n") - } else { - txt.print("fail <= 4f\n") - } - - if ubb <= 2 { - txt.print("fail <= 4g\n") - } else { - txt.print("ok <= 4g\n") - } - - if ubb<=0 { - txt.print("fail <= 4h\n") - } else { - txt.print("ok <= 4h\n") - } - - if ubb<=22 { - txt.print("ok <= 4h2\n") - } else { - txt.print("fail <= 4h2\n") - } - - if uww <= 10000 { - txt.print("ok <= 4i\n") - } else { - txt.print("fail <= 4i\n") - } - - if uww <= 2 { - txt.print("fail <= 4j\n") - } else { - txt.print("ok <= 4j\n") - } - - if uww <= 0 { - txt.print("fail <= 4k\n") - } else { - txt.print("ok <= 4k\n") - } - - if uww <= 2222 { - txt.print("ok <= 4l\n") - } else { - txt.print("fail <= 4l\n") - } - - ; some more special cases for signed comparison - byte b2 = -100 - word w2 = -30000 - if b2 <= -127 { - txt.print("fail <= eb1\n") - } else { - txt.print("ok <= eb1\n") - } - if b2 <= -101 { - txt.print("fail <= eb2\n") - } else { - txt.print("ok <= eb2\n") - } - if b2 <= -100 { - txt.print("ok <= eb3\n") - } else { - txt.print("fail <= eb3\n") - } - if b2 <= -99 { - txt.print("ok <= eb4\n") - } else { - txt.print("fail <= eb4\n") - } - if b2 <= 100 { - txt.print("ok <= eb5\n") - } else { - txt.print("fail <= eb5\n") - } - if b2 <= 127 { - txt.print("ok <= eb6\n") - } else { - txt.print("fail <= eb6\n") - } - if b2 <= 0 { - txt.print("ok <= eb7\n") - } else { - txt.print("fail <= eb7\n") - } - - if w2 <= -32768 { - txt.print("fail <= ew1\n") - } else { - txt.print("ok <= ew1\n") - } - if w2 <= -30001 { - txt.print("fail <= ew2\n") - } else { - txt.print("ok <= ew2\n") - } - if w2 <= -30000 { - txt.print("ok <= ew3\n") - } else { - txt.print("fail <= ew3\n") - } - if w2 <= -29999 { - txt.print("ok <= ew4\n") - } else { - txt.print("fail <= ew4\n") - } - if w2 <= 30000 { - txt.print("ok <= ew5\n") - } else { - txt.print("fail <= ew5\n") - } - if w2 <= 32767 { - txt.print("ok <= ew6\n") - } else { - txt.print("fail <= ew6\n") - } - if w2 <= 0 { - txt.print("ok <= ew7\n") - } else { - txt.print("fail <= ew7\n") - } - - } - - sub greaterequal() { - if bb >= -99 { - txt.print("ok >= 5\n") - } else { - txt.print("fail >= 5\n") - } - - if bb >= -1 { - txt.print("fail >= 6\n") - } else { - txt.print("ok >= 6\n") - } - - if bb >= 0 { - txt.print("fail >= 6b\n") - } else { - txt.print("ok >= 6b\n") - } - - if bb >= -22 { - txt.print("ok >= 6c\n") - } else { - txt.print("fail >= 6c\n") - } - - if ww >= -9999 { - txt.print("ok >= 7\n") - } else { - txt.print("fail >= 7\n") - } - - if ww >= -1 { - txt.print("fail >= 8\n") - } else { - txt.print("ok >= 8\n") - } - - if ww>=0 { - txt.print("fail >= 8b\n") - } else { - txt.print("ok >= 8b\n") - } - - if ww>=-2222 { - txt.print("ok >= 8b2\n") - } else { - txt.print("fail >= 8b2\n") - } - - if ff >= -1.0 { - txt.print("fail >= 8c\n") - } else { - txt.print("ok >= 8c\n") - } - - if ff >= -9999.9 { - txt.print("ok >= 8d\n") - } else { - txt.print("fail >= 8d\n") - } - - if ff >= 0.0 { - txt.print("fail >= 8e\n") - } else { - txt.print("ok >= 8e\n") - } - - if ff >= -2.2 { - txt.print("ok >= 8e2\n") - } else { - txt.print("fail >= 8e2\n") - } - - if ubb >= 5 { - txt.print("ok >= 8f\n") - } else { - txt.print("fail >= 8f\n") - } - - if ubb >= 250 { - txt.print("fail >= 8g\n") - } else { - txt.print("ok >= 8g\n") - } - - if ubb >= 0 { - txt.print("ok >= 8h\n") - } else { - txt.print("fail >= 8h\n") - } - - if ubb >= 22 { - txt.print("ok >= 8h2\n") - } else { - txt.print("fail >= 8h2\n") - } - - if uww >= 5 { - txt.print("ok >= 8i\n") - } else { - txt.print("fail >= 8i\n") - } - - if uww >= 9999 { - txt.print("fail >= 8j\n") - } else { - txt.print("ok >= 8j\n") - } - - if uww>=0 { - txt.print("ok >= 8k\n") - } else { - txt.print("fail >= 8k\n") - } - - if uww>=2222 { - txt.print("ok >= 8l\n") - } else { - txt.print("fail >= 8l\n") - } - - ; some more special cases for signed comparison - byte b2 = -100 - word w2 = -30000 - if b2 >= -127 { - txt.print("ok >= eb1\n") - } else { - txt.print("fail >= eb1\n") - } - if b2 >= -101 { - txt.print("ok >= eb2\n") - } else { - txt.print("fail >= eb2\n") - } - if b2 >= -100 { - txt.print("ok >= eb3\n") - } else { - txt.print("fail >= eb3\n") - } - if b2 >= -99 { - txt.print("fail >= eb4\n") - } else { - txt.print("ok >= eb4\n") - } - if b2 >= 100 { - txt.print("fail >= eb5\n") - } else { - txt.print("ok >= eb5\n") - } - if b2 >= 127 { - txt.print("fail >= eb6\n") - } else { - txt.print("ok >= eb6\n") - } - if b2 >= 0 { - txt.print("fail >= eb7\n") - } else { - txt.print("ok >= eb7\n") - } - - if w2 >= -32768 { - txt.print("ok >= ew1\n") - } else { - txt.print("fail >= ew1\n") - } - if w2 >= -30001 { - txt.print("ok >= ew2\n") - } else { - txt.print("fail >= ew2\n") - } - if w2 >= -30000 { - txt.print("ok >= ew3\n") - } else { - txt.print("fail >= ew3\n") - } - if w2 >= -29999 { - txt.print("fail >= ew4\n") - } else { - txt.print("ok >= ew4\n") - } - if w2 >= 30000 { - txt.print("fail >= ew5\n") - } else { - txt.print("ok >= ew5\n") - } - if w2 >= 32767 { - txt.print("fail >= ew6\n") - } else { - txt.print("ok >= ew6\n") - } - if w2 >= 0 { - txt.print("fail >= ew7\n") - } else { - txt.print("ok >= ew7\n") - } - } -} diff --git a/compiler/test/comparisons/old_ifs_word.p8 b/compiler/test/comparisons/old_ifs_word.p8 deleted file mode 100644 index 15164be95..000000000 --- a/compiler/test/comparisons/old_ifs_word.p8 +++ /dev/null @@ -1,142 +0,0 @@ -%import textio -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - word v1 - word v2 - - v1 = 100 - v2 = 30333 - if v1==v2 - txt.print("error in 100==30333!\n") - else - txt.print("ok: 100 not == 30333\n") - - if v1!=v2 - txt.print("ok: 100 != 30333\n") - else - txt.print("error in 100!=30333!\n") - - if v1v2 - txt.print("error in 100>30333!\n") - else - txt.print("ok: 100 is not >30333\n") - - if v1>=v2 - txt.print("error in 100>=30333!\n") - else - txt.print("ok: 100 is not >=30333\n") - - - v1 = 125 - v2 = -222 - if v1==v2 - txt.print("error in 125==-222!\n") - else - txt.print("ok: 125 not == -222\n") - - if v1!=v2 - txt.print("ok: 125 != -222\n") - else - txt.print("error in 125!=-222!\n") - - if v1v2 - txt.print("ok: 125 > -222\n") - else - txt.print("error in 125>-222!\n") - - if v1>=v2 - txt.print("ok: 125 >= -222\n") - else - txt.print("error in 125>=-222!\n") - - v1 = -222 - v2 = -222 - if v1==v2 - txt.print("ok: -222 == -222\n") - else - txt.print("error in -222==-222!\n") - - if v1!=v2 - txt.print("error in -222!=-222!\n") - else - txt.print("ok: -222 is not != -222\n") - - if v1v2 - txt.print("error in -222>-222!\n") - else - txt.print("ok: -222 is not > -222\n") - - if v1>=v2 - txt.print("ok: -222 >= -222\n") - else - txt.print("error in -222>=-222!\n") - - v1 = 1000 - v2 = 1000 - if v1==v2 - txt.print("ok: 1000 == 1000\n") - else - txt.print("error in 1000==1000!\n") - - if v1!=v2 - txt.print("error in 1000!=1000!\n") - else - txt.print("ok: 1000 is not != 1000\n") - - if v1v2 - txt.print("error in 1000>1000!\n") - else - txt.print("ok: 1000 is not > 1000\n") - - if v1>=v2 - txt.print("ok: 1000 >= 1000\n") - else - txt.print("error in 1000>=1000!\n") - } -} diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 26403131c..a3c696024 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,8 +2,6 @@ TODO ==== -- fix errors in comparison changes (first complete the new comparison test generation tool) -- fix imageviewer only showing first image (likely fixed by the one above) - add cx16 vload() - optimize several inner loops in gfx2 diff --git a/examples/test.p8 b/examples/test.p8 index 1d27a18cc..5a05f1252 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,186 +1,10 @@ %import textio -%zeropage dontuse +%zeropage basicsafe main { + sub start() { - ubyte num_files = 10 - - while num_files { - txt.print_ub(num_files) - txt.nl() - num_files-- - } - } - - sub start2() { - txt.print("\n"*25) - - word xx - word compare - - xx=10 - if xx<9 - txt.print("1fault\n") - else - txt.print("1ok\n") - - if xx<10 - txt.print("2fault\n") - else - txt.print("2ok\n") - - if xx<11 - txt.print("3ok\n") - else - txt.print("3fault\n") - - if xx<2222 - txt.print("4ok\n") - else - txt.print("4fault\n") - - if xx<-9 - txt.print("5fault\n") - else - txt.print("5ok\n") - - if xx<-9999 - txt.print("6fault\n") - else - txt.print("6ok\n") - - if xx<0 - txt.print("7fault\n") - else - txt.print("7ok\n") - - xx=0 - if xx<0 - txt.print("8false\n") - else - txt.print("8ok\n") - - xx=-9999 - if xx<0 - txt.print("9ok\n") - else - txt.print("9fault\n") - - txt.nl() - - xx=10 - compare=9 - if xx