vm: fix comparison datatype error; primes.p8 works again

This commit is contained in:
Irmen de Jong 2022-05-24 18:26:07 +02:00
parent 3f5877dbcc
commit b459b09b2f
4 changed files with 16 additions and 21 deletions

View File

@ -585,7 +585,7 @@ class CodeGen(internal val program: PtProgram,
throw AssemblyError("if condition should only be a binary comparison expression")
val signed = ifElse.condition.left.type in arrayOf(DataType.BYTE, DataType.WORD, DataType.FLOAT)
val vmDt = vmType(ifElse.condition.type)
val vmDt = vmType(ifElse.condition.left.type)
val code = VmCodeChunk()
fun translateNonZeroComparison(): VmCodeChunk {

View File

@ -3,7 +3,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- vm: fix primes.p8 calculating wrong primes
...

View File

@ -40,27 +40,15 @@ main {
return 0 ; we wrapped; no more primes available in the sieve
}
txt.print("candidate: ")
txt.print_ub(candidate_prime)
txt.nl()
; found next one, mark the multiples and return it.
sieve[candidate_prime] = true
uword multiple = candidate_prime
while multiple < len(sieve) {
sieve[lsb(multiple)] = true
multiple += candidate_prime
}
ubyte xx
for xx in sieve {
txt.print_ub(xx)
txt.spc()
}
txt.nl()
return candidate_prime
}
}

View File

@ -33,16 +33,24 @@ main {
ubyte[20] sieve
uword count=0
ubyte xx
for xx in sieve {
txt.print_ub(xx)
if count < 256
txt.print("<256 ok! 1\n")
if count > 256
txt.print(">256 nok! 2\n")
count=257
if count < 256
txt.print("<256 nok! 3\n")
if count > 256
txt.print(">256 ok! 4\n")
count=256
count=0
while count < 256 { ; TODO fix this while loop
txt.print_uw(count)
txt.spc()
count++
count += 10
}
txt.nl()
txt.print_uw(count)
txt.nl()
; ; a "pixelshader":
; sys.gfx_enable(0) ; enable lo res screen