diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt index 64c6b0008..493c49433 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt @@ -491,7 +491,7 @@ internal class AssignmentAsmGen(private val program: PtProgram, cpy P8ZP_SCRATCH_W1+1 bne + lda #0 - bne ++ + beq ++ + lda #1 +""") } diff --git a/compiler/test/comparisons/test_compares.p8 b/compiler/test/comparisons/test_compares.p8 new file mode 100644 index 000000000..e2ad47107 --- /dev/null +++ b/compiler/test/comparisons/test_compares.p8 @@ -0,0 +1,120 @@ +%zeropage basicsafe +%import textio + +main { + sub start() { + byte b = -100 + ubyte ub = 20 + word w = -20000 + uword uw = 2000 + + txt.print("all 1: ") + txt.print_ub(b == -100) + txt.print_ub(b != -99) + txt.print_ub(b < -99) + txt.print_ub(b <= -100) + txt.print_ub(b > -101) + txt.print_ub(b >= -100) + txt.print_ub(ub ==20) + txt.print_ub(ub !=19) + txt.print_ub(ub <21) + txt.print_ub(ub <=20) + txt.print_ub(ub>19) + txt.print_ub(ub>=20) + txt.spc() + txt.print_ub(w == -20000) + txt.print_ub(w != -19999) + txt.print_ub(w < -19999) + txt.print_ub(w <= -20000) + txt.print_ub(w > -20001) + txt.print_ub(w >= -20000) + txt.print_ub(uw == 2000) + txt.print_ub(uw != 2001) + txt.print_ub(uw < 2001) + txt.print_ub(uw <= 2000) + txt.print_ub(uw > 1999) + txt.print_ub(uw >= 2000) + txt.nl() + txt.print("all 0: ") + txt.print_ub(b == -99) + txt.print_ub(b != -100) + txt.print_ub(b < -100) + txt.print_ub(b <= -101) + txt.print_ub(b > -100) + txt.print_ub(b >= -99) + txt.print_ub(ub ==21) + txt.print_ub(ub !=20) + txt.print_ub(ub <20) + txt.print_ub(ub <=19) + txt.print_ub(ub>20) + txt.print_ub(ub>=21) + txt.spc() + txt.print_ub(w == -20001) + txt.print_ub(w != -20000) + txt.print_ub(w < -20000) + txt.print_ub(w <= -20001) + txt.print_ub(w > -20000) + txt.print_ub(w >= -19999) + txt.print_ub(uw == 1999) + txt.print_ub(uw != 2000) + txt.print_ub(uw < 2000) + txt.print_ub(uw <= 1999) + txt.print_ub(uw > 2000) + txt.print_ub(uw >= 2001) + txt.nl() + + + b = -100 + while b <= -20 + b++ + txt.print_b(b) + txt.print(" -19\n") + b = -100 + while b < -20 + b++ + txt.print_b(b) + txt.print(" -20\n") + + ub = 20 + while ub <= 200 + ub++ + txt.print_ub(ub) + txt.print(" 201\n") + ub = 20 + while ub < 200 + ub++ + txt.print_ub(ub) + txt.print(" 200\n") + + w = -20000 + while w <= -8000 { + w++ + } + txt.print_w(w) + txt.print(" -7999\n") + w = -20000 + while w < -8000 { + w++ + } + txt.print_w(w) + txt.print(" -8000\n") + + uw = 2000 + while uw <= 8000 { + uw++ + } + txt.print_uw(uw) + txt.print(" 8001\n") + uw = 2000 + while uw < 8000 { + uw++ + } + txt.print_uw(uw) + txt.print(" 8000\n") + +; float f +; while f<2.2 { +; f+=0.1 +; } + } +}