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 / a64 / tests / ref / ar.om

60 lines · 1042 bytes Raw Blame History
1note ref/ar.om: omc reference of mkir fixture ar (exit = the u64 fold of w[0 .. 14) low byte)
2global w ulong 16
3
4fn mx a uint b uint to uint
5if gt a b
6ret a
7end
8ret b
9end
10
11fn mn c int d int to int
12if lt c d
13ret c
14end
15ret d
16end
17
18fn sel c int d int a uint b uint to uint
19if lt c d
20ret a
21end
22ret b
23end
24
25fn ar1 a uint b uint c int d int to void
26put w 0 ulong or shl a 7 shr a 25
27put w 1 ulong or shr b 13 shl b 19
28put w 2 ulong shl a 9
29put w 3 ulong mx a b
30put w 4 ulong add a b
31put w 5 ulong mul a b
32put w 6 ulong sel c d a b
33put w 7 ulong and add and a 255 200 255
34put w 8 ulong shr b 5
35end
36
37fn ar2 c int d int to void
38off = int 1073741824
39put w 9 ulong add shr c 3 off
40put w 10 ulong add div c d off
41put w 11 ulong add rem c d off
42put w 12 ulong add mn c d off
43put w 13 ulong add sub c d off
44end
45
46fn ar a uint b uint c int d int to ulong
47ar1 a b c d
48ar2 c d
49s = ulong 0
50k = ulong 0
51while lt k 14 bound 14
52s = add mul s 1000003 get w k
53k = add k 1
54end
55ret s
56end
57
58fn main to int
59ret int and ar 2654435769 2135587861 sub int 0 1000003 77 255
60end