diff --git a/compiler/src/prog8/optimizer/ExpressionSimplifier.kt b/compiler/src/prog8/optimizer/ExpressionSimplifier.kt index ba971d7c9..9bab6d40c 100644 --- a/compiler/src/prog8/optimizer/ExpressionSimplifier.kt +++ b/compiler/src/prog8/optimizer/ExpressionSimplifier.kt @@ -175,28 +175,6 @@ internal class ExpressionSimplifier(private val program: Program) : AstWalker() // unsigned >= 0 --> true return listOf(IAstModification.ReplaceNode(expr, NumericLiteralValue.fromBoolean(true, expr.position), parent)) } - when(leftDt) { - DataType.BYTE -> { - // signed >=0 --> signed ^ $80 - return listOf(IAstModification.ReplaceNode( - expr, - BinaryExpression(expr.left, "^", NumericLiteralValue.optimalInteger(0x80, expr.position), expr.position), - parent - )) - } - DataType.WORD -> { - // signedw >=0 --> msb(signedw) ^ $80 - return listOf(IAstModification.ReplaceNode( - expr, - BinaryExpression(FunctionCall(IdentifierReference(listOf("msb"), expr.position), - mutableListOf(expr.left), - expr.position - ), "^", NumericLiteralValue.optimalInteger(0x80, expr.position), expr.position), - parent - )) - } - else -> {} - } } if(expr.operator == "<" && rightVal?.number == 0) { diff --git a/examples/cmp/comparisons_byte.p8 b/examples/cmp/comparisons_byte.p8 deleted file mode 100644 index 9ea80f72b..000000000 --- a/examples/cmp/comparisons_byte.p8 +++ /dev/null @@ -1,95 +0,0 @@ -%import textio -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - byte v1 - byte v2 - ubyte cr - - txt.print("signed byte ") - - cr=v1==v2 - cr=v1==v2 - cr=v1==v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - - ; comparisons: - v1=-20 - v2=125 - txt.print("v1=-20, v2=125\n") - compare() - - v1=80 - v2=80 - txt.print("v1 = v2 = 80\n") - compare() - - v1=20 - v2=-111 - txt.print("v1=20, v2=-111\n") - compare() - - return - - sub compare() { - txt.print(" == != < > <= >=\n") - - if v1==v2 - txt.print(" Q ") - else - txt.print(" . ") - if v1!=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1<=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1>=v2 - txt.print(" Q ") - else - txt.print(" . ") - c64.CHROUT('\n') - - } - - } -} diff --git a/examples/cmp/comparisons_float.p8 b/examples/cmp/comparisons_float.p8 deleted file mode 100644 index 5f415700f..000000000 --- a/examples/cmp/comparisons_float.p8 +++ /dev/null @@ -1,112 +0,0 @@ -%import textio -%import floats -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - float v1 - float v2 - ubyte cr - - txt.print("floating point ") - - cr=v1==v2 - cr=v1==v2 - cr=v1==v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - - ; comparisons: - v1=20 - v2=666.66 - txt.print("v1=20, v2=666.66\n") - compare() - - v1=-20 - v2=666.66 - txt.print("v1=-20, v2=666.66\n") - compare() - - v1=666.66 - v2=555.55 - txt.print("v1=666.66, v2=555.55\n") - compare() - - v1=3.1415 - v2=-3.1415 - txt.print("v1 = 3.1415, v2 = -3.1415\n") - compare() - - v1=3.1415 - v2=3.1415 - txt.print("v1 = v2 = 3.1415\n") - compare() - - v1=0 - v2=0 - txt.print("v1 = v2 = 0\n") - compare() - - return - - sub compare() { - txt.print(" == != < > <= >=\n") - - if v1==v2 - txt.print(" Q ") - else - txt.print(" . ") - if v1!=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1<=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1>=v2 - txt.print(" Q ") - else - txt.print(" . ") - c64.CHROUT('\n') - - } - - } - -} diff --git a/examples/cmp/comparisons_ubyte.p8 b/examples/cmp/comparisons_ubyte.p8 deleted file mode 100644 index fc344be93..000000000 --- a/examples/cmp/comparisons_ubyte.p8 +++ /dev/null @@ -1,96 +0,0 @@ -%import textio -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - ubyte v1 - ubyte v2 - ubyte cr - - txt.print("unsigned byte ") - - cr=v1==v2 - cr=v1==v2 - cr=v1==v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - - ; comparisons: - v1=20 - v2=199 - txt.print("v1=20, v2=199\n") - compare() - - v1=80 - v2=80 - txt.print("v1 = v2 = 80\n") - compare() - - v1=220 - v2=10 - txt.print("v1=220, v2=10\n") - compare() - - return - - sub compare() { - txt.print(" == != < > <= >=\n") - - if v1==v2 - txt.print(" Q ") - else - txt.print(" . ") - if v1!=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1<=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1>=v2 - txt.print(" Q ") - else - txt.print(" . ") - c64.CHROUT('\n') - - } - - } - -} diff --git a/examples/cmp/comparisons_uword.p8 b/examples/cmp/comparisons_uword.p8 deleted file mode 100644 index 130587246..000000000 --- a/examples/cmp/comparisons_uword.p8 +++ /dev/null @@ -1,125 +0,0 @@ -%import textio -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - uword v1 - uword v2 - ubyte cr - - txt.print("unsigned word ") - - cr=v1==v2 - cr=v1==v2 - cr=v1==v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - - ; comparisons: - v1=20 - v2=$00aa - txt.print("v1=20, v2=$00aa\n") - compare() - - v1=20 - v2=$ea00 - txt.print("v1=20, v2=$ea00\n") - compare() - - v1=$c400 - v2=$22 - txt.print("v1=$c400, v2=$22\n") - compare() - - v1=$c400 - v2=$2a00 - txt.print("v1=$c400, v2=$2a00\n") - compare() - - v1=$c433 - v2=$2a00 - txt.print("v1=$c433, v2=$2a00\n") - compare() - - v1=$c433 - v2=$2aff - txt.print("v1=$c433, v2=$2aff\n") - compare() - - v1=$aabb - v2=$aabb - txt.print("v1 = v2 = aabb\n") - compare() - - v1=$aa00 - v2=$aa00 - txt.print("v1 = v2 = aa00\n") - compare() - - v1=$aa - v2=$aa - txt.print("v1 = v2 = aa\n") - compare() - - return - - sub compare() { - txt.print(" == != < > <= >=\n") - - if v1==v2 - txt.print(" Q ") - else - txt.print(" . ") - if v1!=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1<=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1>=v2 - txt.print(" Q ") - else - txt.print(" . ") - c64.CHROUT('\n') - - } - - } -} diff --git a/examples/cmp/comparisons_word.p8 b/examples/cmp/comparisons_word.p8 deleted file mode 100644 index bd0900030..000000000 --- a/examples/cmp/comparisons_word.p8 +++ /dev/null @@ -1,161 +0,0 @@ -%import textio -%zeropage basicsafe - -; Note: this program is compatible with C64 and CX16. - -main { - - sub start() { - - word v1 - word v2 - ubyte cr - - txt.print("signed word ") - - cr=v1==v2 - cr=v1==v2 - cr=v1==v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1!=v2 - cr=v1v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1>v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1<=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - cr=v1>=v2 - - ; comparisons: - v1=20 - v2=$00aa - txt.print("v1=20, v2=$00aa\n") - compare() - - v1=20 - v2=$7a00 - txt.print("v1=20, v2=$7a00\n") - compare() - - v1=$7400 - v2=$22 - txt.print("v1=$7400, v2=$22\n") - compare() - - v1=$7400 - v2=$2a00 - txt.print("v1=$7400, v2=$2a00\n") - compare() - - v1=$7433 - v2=$2a00 - txt.print("v1=$7433, v2=$2a00\n") - compare() - - v1=$7433 - v2=$2aff - txt.print("v1=$7433, v2=$2aff\n") - compare() - - ; with negative numbers: - v1=-512 - v2=$00aa - txt.print("v1=-512, v2=$00aa\n") - compare() - - v1=-512 - v2=$7a00 - txt.print("v1=-512, v2=$7a00\n") - compare() - - v1=$7400 - v2=-512 - txt.print("v1=$7400, v2=-512\n") - compare() - - v1=-20000 - v2=-1000 - txt.print("v1=-20000, v2=-1000\n") - compare() - - v1=-1000 - v2=-20000 - txt.print("v1=-1000, v2=-20000\n") - compare() - - v1=-1 - v2=32767 - txt.print("v1=-1, v2=32767\n") - compare() - - v1=32767 - v2=-1 - txt.print("v1=32767, v2=-1\n") - compare() - - v1=$7abb - v2=$7abb - txt.print("v1 = v2 = 7abb\n") - compare() - - v1=$7a00 - v2=$7a00 - txt.print("v1 = v2 = 7a00\n") - compare() - - v1=$aa - v2=$aa - txt.print("v1 = v2 = aa\n") - compare() - - return - - sub compare() { - txt.print(" == != < > <= >=\n") - - if v1==v2 - txt.print(" Q ") - else - txt.print(" . ") - if v1!=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1<=v2 - txt.print(" Q ") - else - txt.print(" . ") - - if v1>=v2 - txt.print(" Q ") - else - txt.print(" . ") - c64.CHROUT('\n') - - } - - } -}