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 / arith-s.om

34 lines · 880 bytes Raw Blame History
1note arith-s: kernels/arith.om with i = 0 .. 1999999 (was 39999999), for ngrun in gate-front-ir. arith:
2note wrapping multiply-add hash h = h*31 + i and s = sum of ((i*i) xor (i >> 3)) rem 1000003,
3note all ulong (unsigned wraps modulo 2^64). Prints h then s.
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
7fn putnum fd int v ulong to void
8put out 31 10
9p = ulong 31
10x = v
11while gt x 9
12p = sub p 1
13put out p uchar add rem x 10 48
14x = div x 10
15end
16p = sub p 1
17put out p uchar add x 48
18w = write fd out p sub 32 p
19end
20fn main to int
21t0 = monons
22h = ulong 0
23s = ulong 0
24for i ulong 2000000
25h = add mul h 31 i
26t = xor mul i i shr i 3
27s = add s rem t 1000003
28end
29t1 = monons
30putnum 2 ulong sub t1 t0
31putnum 1 h
32putnum 1 s
33ret 0
34end