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 / bench / omc_efficiency / kernels / om2 / arith.om

34 lines · 812 bytes Raw Blame History
1note arith: wrapping multiply-add hash h = h*31 + i and s = sum of ((i*i) xor (i >> 3)) rem 1000003,
2note i = 0 .. 39999999, all ulong (unsigned wraps modulo 2^64). Prints h then s.
3note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
4note start-up and output) as one decimal line on stderr; stdout is unchanged.
5om2
6global obuf uchar 32
7fn putnum fd int v ulong to void
8put obuf 31 10
9p = ulong 31
10x = v
11while gt x 9
12p = sub p 1
13put obuf p uchar add rem x 10 48
14x = div x 10
15end
16p = sub p 1
17put obuf p uchar add x 48
18w = write fd obuf p sub 32 p
19end
20fn main to int
21t0 = monons
22h = ulong 0
23s = ulong 0
24for i ulong 40000000
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