Compare commits

..

No commits in common. "a1ebc7090d16229106a25de86bab03cf13d04992" and "e3e7b060b720503e7f42c60b2aefd806caa34f65" have entirely different histories.

4 changed files with 17 additions and 8 deletions

View File

@ -119,13 +119,14 @@ This code calculates prime numbers using the Sieve of Eratosthenes algorithm::
%import textio
%zeropage basicsafe
main {
bool[256] sieve
ubyte[256] sieve
ubyte candidate_prime = 2 ; is increased in the loop
sub start() {
sys.memset(sieve, 256, 0) ; clear the sieve
sys.memset(sieve, 256, false) ; clear the sieve
txt.print("prime numbers up to 255:\n\n")
ubyte amount=0
repeat {
@ -161,6 +162,9 @@ This code calculates prime numbers using the Sieve of Eratosthenes algorithm::
}
}
when compiled an ran on a C-64 you'll get:
![c64 screen](docs/source/_static/primes_example.png)

View File

@ -120,11 +120,13 @@ This code calculates prime numbers using the Sieve of Eratosthenes algorithm::
%zeropage basicsafe
main {
bool[256] sieve
ubyte[256] sieve
ubyte candidate_prime = 2 ; is increased in the loop
sub start() {
sys.memset(sieve, 256, 0) ; clear the sieve
; clear the sieve, to reset starting situation on subsequent runs
sys.memset(sieve, 256, false)
; calculate primes
txt.print("prime numbers up to 255:\n\n")
ubyte amount=0
repeat {
@ -145,7 +147,7 @@ This code calculates prime numbers using the Sieve of Eratosthenes algorithm::
while sieve[candidate_prime] {
candidate_prime++
if candidate_prime==0
return 0 ; we wrapped; no more primes
return 0 ; we wrapped; no more primes available in the sieve
}
; found next one, mark the multiples and return it.

View File

@ -4,11 +4,12 @@
; Note: this program can be compiled for multiple target systems.
main {
bool[256] sieve
ubyte candidate_prime = 2 ; is increased in the loop
sub start() {
sys.memset(sieve, 256, 0) ; clear the sieve
sys.memset(sieve, 256, 0) ; clear the sieve, to reset starting situation on subsequent runs
; calculate primes
txt.print("prime numbers up to 255:\n\n")
@ -25,6 +26,8 @@ main {
txt.print("number of primes (expected 54): ")
txt.print_ub(amount)
txt.nl()
; test_stack.test()
}

View File

@ -5,4 +5,4 @@ org.gradle.daemon=true
kotlin.code.style=official
javaVersion=11
kotlinVersion=1.9.22
version=10.3
version=10.3-SNAPSHOT