fix word comparison bug in asmgen

This commit is contained in:
Irmen de Jong 2023-03-26 23:44:06 +02:00
parent 1fa2e2e37d
commit a7b9f53967
2 changed files with 121 additions and 1 deletions

View File

@ -491,7 +491,7 @@ internal class AssignmentAsmGen(private val program: PtProgram,
cpy P8ZP_SCRATCH_W1+1 cpy P8ZP_SCRATCH_W1+1
bne + bne +
lda #0 lda #0
bne ++ beq ++
+ lda #1 + lda #1
+""") +""")
} }

View File

@ -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
; }
}
}