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 / qualification / om2 / sec / s3s4 / rot-trap-om1.om

137 lines · 2310 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note OM-1 twin of rot-trap.om (contract section 3 lines 79-81) for the pinned compiler 734f0a39: the
3note rotations are the OM-1 shift helpers tr*/tl* (n = 0 returns x, else shr/shl by n first), so
4note every selector A-O reaches an OM-1 shift by n >= w, which traps 7 (OMEGESE 9.3): exit 107, no
5note stdout. P prints rotr uint 4041331395 by 31. Same expectations as the OM-2 unit.
6note (this line replaces the om2 line, so the line numbers equal those of rot-trap.om)
7note OM-1 unit
8fn rr8 x uchar n uchar to uchar
9ret tr8 x n
10end
11fn rl8 x uchar n uchar to uchar
12ret tl8 x n
13end
14fn rr16 x ushort n ushort to ushort
15ret tr16 x n
16end
17fn rl16 x ushort n ushort to ushort
18ret tl16 x n
19end
20fn rr32 x uint n uint to uint
21ret tr32 x n
22end
23fn rl32 x uint n uint to uint
24ret tl32 x n
25end
26fn rr64 x ulong n ulong to ulong
27ret tr64 x n
28end
29fn rl64 x ulong n ulong to ulong
30ret tl64 x n
31end
32fn main to int
33s = new uchar 1 0
34r = read 0 s 0 1
35k = get s 0
36a = uchar 177
37b = ushort 45508
38c = uint 4041331395
39d = ulong 9305357566071262703
40if eq k 65
41pu ulong tr8 a 8
42end
43if eq k 66
44pu ulong tl16 b 16
45end
46if eq k 67
47pu ulong tr32 c 32
48end
49if eq k 68
50pu tl64 d 64
51end
52if eq k 69
53pu ulong rl8 a 8
54end
55if eq k 70
56pu ulong rr16 b 16
57end
58if eq k 71
59pu ulong rl32 c 32
60end
61if eq k 72
62pu rr64 d 64
63end
64if eq k 73
65pu ulong rr8 a 9
66end
67if eq k 74
68pu ulong rl16 b 65535
69end
70if eq k 75
71pu ulong rr32 c 4294967295
72end
73if eq k 76
74pu rl64 d 18446744073709551615
75end
76if eq k 77
77pu ulong tr32 c 33
78end
79if eq k 78
80pu tl64 d 65
81end
82if eq k 79
83pu ulong tl8 a 255
84end
85if eq k 80
86pu ulong tr32 c 31
87end
88ret 0
89end
90fn tr8 x uchar n uchar to uchar
91if eq n 0
92ret x
93end
94ret or shr x n shl x sub 8 n
95end
96fn tl8 x uchar n uchar to uchar
97if eq n 0
98ret x
99end
100ret or shl x n shr x sub 8 n
101end
102fn tr16 x ushort n ushort to ushort
103if eq n 0
104ret x
105end
106ret or shr x n shl x sub 16 n
107end
108fn tl16 x ushort n ushort to ushort
109if eq n 0
110ret x
111end
112ret or shl x n shr x sub 16 n
113end
114fn tr32 x uint n uint to uint
115if eq n 0
116ret x
117end
118ret or shr x n shl x sub 32 n
119end
120fn tl32 x uint n uint to uint
121if eq n 0
122ret x
123end
124ret or shl x n shr x sub 32 n
125end
126fn tr64 x ulong n ulong to ulong
127if eq n 0
128ret x
129end
130ret or shr x n shl x sub 64 n
131end
132fn tl64 x ulong n ulong to ulong
133if eq n 0
134ret x
135end
136ret or shl x n shr x sub 64 n
137end