fixed issues in uword '>'

This commit is contained in:
Irmen de Jong 2021-03-16 23:40:32 +01:00
parent 00b9766aea
commit 9a6bd760bd
2 changed files with 96 additions and 86 deletions

View File

@ -622,17 +622,18 @@ 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
bcc $jumpIfFalseLabel bcs $jumpIfFalseLabel
bne + bne +
cmp $lsbCmpOperand cmp $lsbCmpOperand
bcc $jumpIfFalseLabel bcs $jumpIfFalseLabel
beq $jumpIfFalseLabel
+""") +""")
} }
if(rightConstVal!=null) { if(rightConstVal!=null) {
if(leftConstVal!=null) { if(leftConstVal!=null) {
if(rightConstVal<=leftConstVal) if(rightConstVal<=leftConstVal)

View File

@ -1,177 +1,186 @@
%import textio %import textio
%zeropage basicsafe %zeropage dontuse
main { main {
sub start() { sub start() {
ubyte num_files = 10
while num_files {
txt.print_ub(num_files)
txt.nl()
num_files--
}
}
sub start2() {
txt.print("\n"*25) txt.print("\n"*25)
word xx word xx
word compare word compare
xx=10 xx=10
if xx>9 if xx<9
txt.print("1ok\n")
else
txt.print("1fault\n") txt.print("1fault\n")
else
txt.print("1ok\n")
if xx>10 if xx<10
txt.print("2fault\n") txt.print("2fault\n")
else else
txt.print("2ok\n") txt.print("2ok\n")
if xx>11 if xx<11
txt.print("3fault\n")
else
txt.print("3ok\n") txt.print("3ok\n")
if xx>2222
txt.print("4fault\n")
else else
txt.print("3fault\n")
if xx<2222
txt.print("4ok\n") txt.print("4ok\n")
if xx>-9
txt.print("5ok\n")
else else
txt.print("4fault\n")
if xx<-9
txt.print("5fault\n") txt.print("5fault\n")
if xx>-9999
txt.print("6ok\n")
else else
txt.print("5ok\n")
if xx<-9999
txt.print("6fault\n") txt.print("6fault\n")
if xx>0
txt.print("7ok\n")
else else
txt.print("6ok\n")
if xx<0
txt.print("7fault\n") txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0 xx=0
if xx>0 if xx<0
txt.print("8false\n") txt.print("8false\n")
else else
txt.print("8ok\n") txt.print("8ok\n")
xx=-9999 xx=-9999
if xx>0 if xx<0
txt.print("9false\n")
else
txt.print("9ok\n") txt.print("9ok\n")
else
txt.print("9fault\n")
txt.nl() txt.nl()
xx=10 xx=10
compare=9 compare=9
if xx>compare if xx<compare
txt.print("1ok\n")
else
txt.print("1fault\n") txt.print("1fault\n")
else
txt.print("1ok\n")
compare=10 compare=10
if xx>compare if xx<compare
txt.print("2fault\n") txt.print("2fault\n")
else else
txt.print("2ok\n") txt.print("2ok\n")
compare=11 compare=11
if xx>compare if xx<compare
txt.print("3fault\n")
else
txt.print("3ok\n") txt.print("3ok\n")
else
txt.print("3fault\n")
compare=2222 compare=2222
if xx>compare if xx<compare
txt.print("4fault\n")
else
txt.print("4ok\n") txt.print("4ok\n")
else
txt.print("4fault\n")
compare=-9 compare=-9
if xx>compare if xx<compare
txt.print("5ok\n")
else
txt.print("5fault\n") txt.print("5fault\n")
else
txt.print("5ok\n")
compare=-9999 compare=-9999
if xx>compare if xx<compare
txt.print("6ok\n")
else
txt.print("6fault\n") txt.print("6fault\n")
else
txt.print("6ok\n")
compare=0 compare=0
if xx>compare if xx<compare
txt.print("7ok\n")
else
txt.print("7fault\n") txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0 xx=0
if xx>compare if xx<compare
txt.print("8false\n") txt.print("8fault\n")
else else
txt.print("8ok\n") txt.print("8ok\n")
xx=-9999 xx=-9999
if xx>compare if xx<compare
txt.print("9false\n")
else
txt.print("9ok\n") txt.print("9ok\n")
else
txt.print("9fault\n")
txt.nl() txt.nl()
xx=9 xx=10
compare=9 compare=8
if xx+1>compare if xx<compare+1
txt.print("1ok\n")
else
txt.print("1fault\n") txt.print("1fault\n")
else
txt.print("1ok\n")
compare=10 compare=9
if xx+1>compare if xx<compare+1
txt.print("2fault\n") txt.print("2fault\n")
else else
txt.print("2ok\n") txt.print("2ok\n")
compare=11 compare=10
if xx+1>compare if xx<compare+1
txt.print("3fault\n")
else
txt.print("3ok\n") txt.print("3ok\n")
else
txt.print("3fault\n")
compare=2222 compare=2222
if xx+1>compare if xx<compare+1
txt.print("4fault\n")
else
txt.print("4ok\n") txt.print("4ok\n")
compare=-9
if xx+1>compare
txt.print("5ok\n")
else else
txt.print("4fault\n")
compare=-8
if xx<compare-1
txt.print("5fault\n") txt.print("5fault\n")
else
txt.print("5ok\n")
compare=-9999 compare=-9999
if xx+1>compare if xx<compare-1
txt.print("6ok\n")
else
txt.print("6fault\n") txt.print("6fault\n")
compare=0
if xx+1>compare
txt.print("7ok\n")
else else
txt.print("7fault\n") txt.print("6ok\n")
xx=1 compare=1
if xx-1>compare if xx<compare-1
txt.print("8false\n") txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0
if xx<compare-1
txt.print("8fault\n")
else else
txt.print("8ok\n") txt.print("8ok\n")
xx=-9999 xx=-9999
if xx-1>compare if xx<compare-1
txt.print("9false\n")
else
txt.print("9ok\n") txt.print("9ok\n")
else
txt.print("9fault\n")
} }
} }