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) {
// TODO verify correctness uword >
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
asmgen.out("""
cpy $msbCpyOperand
bcc $jumpIfFalseLabel
bcs $jumpIfFalseLabel
bne +
cmp $lsbCmpOperand
bcc $jumpIfFalseLabel
beq $jumpIfFalseLabel
bcs $jumpIfFalseLabel
+""")
}
if(rightConstVal!=null) {
if(leftConstVal!=null) {
if(rightConstVal<=leftConstVal)

View File

@ -1,177 +1,186 @@
%import textio
%zeropage basicsafe
%zeropage dontuse
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("1ok\n")
else
if xx<9
txt.print("1fault\n")
else
txt.print("1ok\n")
if xx>10
if xx<10
txt.print("2fault\n")
else
txt.print("2ok\n")
if xx>11
txt.print("3fault\n")
else
if xx<11
txt.print("3ok\n")
if xx>2222
txt.print("4fault\n")
else
txt.print("3fault\n")
if xx<2222
txt.print("4ok\n")
if xx>-9
txt.print("5ok\n")
else
txt.print("4fault\n")
if xx<-9
txt.print("5fault\n")
if xx>-9999
txt.print("6ok\n")
else
txt.print("5ok\n")
if xx<-9999
txt.print("6fault\n")
if xx>0
txt.print("7ok\n")
else
txt.print("6ok\n")
if xx<0
txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0
if xx>0
if xx<0
txt.print("8false\n")
else
txt.print("8ok\n")
xx=-9999
if xx>0
txt.print("9false\n")
else
if xx<0
txt.print("9ok\n")
else
txt.print("9fault\n")
txt.nl()
xx=10
compare=9
if xx>compare
txt.print("1ok\n")
else
if xx<compare
txt.print("1fault\n")
else
txt.print("1ok\n")
compare=10
if xx>compare
if xx<compare
txt.print("2fault\n")
else
txt.print("2ok\n")
compare=11
if xx>compare
txt.print("3fault\n")
else
if xx<compare
txt.print("3ok\n")
else
txt.print("3fault\n")
compare=2222
if xx>compare
txt.print("4fault\n")
else
if xx<compare
txt.print("4ok\n")
else
txt.print("4fault\n")
compare=-9
if xx>compare
txt.print("5ok\n")
else
if xx<compare
txt.print("5fault\n")
else
txt.print("5ok\n")
compare=-9999
if xx>compare
txt.print("6ok\n")
else
if xx<compare
txt.print("6fault\n")
else
txt.print("6ok\n")
compare=0
if xx>compare
txt.print("7ok\n")
else
if xx<compare
txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0
if xx>compare
txt.print("8false\n")
if xx<compare
txt.print("8fault\n")
else
txt.print("8ok\n")
xx=-9999
if xx>compare
txt.print("9false\n")
else
if xx<compare
txt.print("9ok\n")
else
txt.print("9fault\n")
txt.nl()
xx=9
compare=9
if xx+1>compare
txt.print("1ok\n")
else
xx=10
compare=8
if xx<compare+1
txt.print("1fault\n")
else
txt.print("1ok\n")
compare=10
if xx+1>compare
compare=9
if xx<compare+1
txt.print("2fault\n")
else
txt.print("2ok\n")
compare=11
if xx+1>compare
txt.print("3fault\n")
else
compare=10
if xx<compare+1
txt.print("3ok\n")
else
txt.print("3fault\n")
compare=2222
if xx+1>compare
txt.print("4fault\n")
else
if xx<compare+1
txt.print("4ok\n")
compare=-9
if xx+1>compare
txt.print("5ok\n")
else
txt.print("4fault\n")
compare=-8
if xx<compare-1
txt.print("5fault\n")
else
txt.print("5ok\n")
compare=-9999
if xx+1>compare
txt.print("6ok\n")
else
if xx<compare-1
txt.print("6fault\n")
compare=0
if xx+1>compare
txt.print("7ok\n")
else
txt.print("7fault\n")
txt.print("6ok\n")
xx=1
if xx-1>compare
txt.print("8false\n")
compare=1
if xx<compare-1
txt.print("7fault\n")
else
txt.print("7ok\n")
xx=0
if xx<compare-1
txt.print("8fault\n")
else
txt.print("8ok\n")
xx=-9999
if xx-1>compare
txt.print("9false\n")
else
if xx<compare-1
txt.print("9ok\n")
else
txt.print("9fault\n")
}
}