interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / front / runs / sieve-s.om

57 lines · 1146 bytes Raw Blame History
1note sieve-s: kernels/sieve.om with 2 passes (was 50), for ngrun in gate-front-ir. sieve: fresh
2note passes of the sieve of Eratosthenes over 0 .. 2000000 in a global byte array;
3note prints the prime count of the last pass and the sum of the counts of all passes.
4note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
5note start-up and output) as one decimal line on stderr; stdout is unchanged.
6global out uchar 32
7global fl uchar 2000001
8fn putnum fd int v ulong to void
9put out 31 10
10p = ulong 31
11x = v
12while gt x 9
13p = sub p 1
14put out p uchar add rem x 10 48
15x = div x 10
16end
17p = sub p 1
18put out p uchar add x 48
19w = write fd out p sub 32 p
20end
21fn pass to ulong
22for i ulong 2000001
23put fl i 0
24end
25p = ulong 2
26while le mul p p 2000000
27if eq get fl p 0
28m = mul p p
29while le m 2000000
30put fl m 1
31m = add m p
32end
33end
34p = add p 1
35end
36c = ulong 0
37for i ulong 1999999
38if eq get fl add i 2 0
39c = add c 1
40end
41end
42ret c
43end
44fn main to int
45t0 = monons
46sum = ulong 0
47last = ulong 0
48for r ulong 2
49last = pass
50sum = add sum last
51end
52t1 = monons
53putnum 2 ulong sub t1 t0
54putnum 1 last
55putnum 1 sum
56ret 0
57end