Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/front/runs/sieve-s.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / front / runs / sieve-s.om` 57 lines ยท 1146 bytes Raw Blame History 1 note sieve-s: kernels/sieve.om with 2 passes (was 50), for ngrun in gate-front-ir. sieve: fresh 2 note passes of the sieve of Eratosthenes over 0 .. `2000000` in a global byte array; 3 note prints the prime count of the last pass and the sum of the counts of all passes. 4 note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without 5 note start-up and output) as one decimal line on stderr; stdout is unchanged. 6 global out uchar 32 7 global fl uchar `2000001` 8 fn putnum fd int v ulong to void 9 put out 31 10 10 p = ulong 31 11 x = v 12 while gt x 9 13 p = sub p 1 14 put out p uchar add rem x 10 48 15 x = div x 10 16 end 17 p = sub p 1 18 put out p uchar add x 48 19 w = write fd out p sub 32 p 20 end 21 fn pass to ulong 22 for i ulong `2000001` 23 put fl i 0 24 end 25 p = ulong 2 26 while le mul p p `2000000` 27 if eq get fl p 0 28 m = mul p p 29 while le m `2000000` 30 put fl m 1 31 m = add m p 32 end 33 end 34 p = add p 1 35 end 36 c = ulong 0 37 for i ulong `1999999` 38 if eq get fl add i 2 0 39 c = add c 1 40 end 41 end 42 ret c 43 end 44 fn main to int 45 t0 = monons 46 sum = ulong 0 47 last = ulong 0 48 for r ulong 2 49 last = pass 50 sum = add sum last 51 end 52 t1 = monons 53 putnum 2 ulong sub t1 t0 54 putnum 1 last 55 putnum 1 sum 56 ret 0 57 end