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 / s5s7 / om1 / t-endian.om

45 lines · 1069 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note OM-1 twin of l5-endian.om: big-endian fields stored MSB first, little-endian LSB first, then
3note decoded back from the bytes. Expected stdout oracle/s5s7/exp/l5-endian.out (python3 struct).
4note 168496141 = 0x0a0b0c0d, 72623859790382856 = 0x0102030405060708, 48879 = 0xbeef, 4660 = 0x1234.
5fn stbe c edit uchar 16 o ulong v ulong n ulong to void
6x = v
7for i ulong n
8put c add o sub sub n 1 i uchar and x 255
9x = shr x 8
10end
11end
12fn stle c edit uchar 16 o ulong v ulong n ulong to void
13x = v
14for i ulong n
15put c add o i uchar and x 255
16x = shr x 8
17end
18end
19fn gbe c view uchar 16 o ulong n ulong to ulong
20x = ulong 0
21for i ulong n
22x = or shl x 8 ulong get c add o i
23end
24ret x
25end
26fn gle c view uchar 16 o ulong n ulong to ulong
27x = ulong 0
28for i ulong n
29x = or shl x 8 ulong get c add o sub sub n 1 i
30end
31ret x
32end
33fn main to int
34c = new uchar 16 0
35stbe c 0 168496141 4
36stbe c 4 72623859790382856 8
37stle c 12 48879 2
38stle c 14 4660 2
39w = write 1 c 0 16
40puth gbe c 0 4
41puth gbe c 4 8
42puth gle c 12 2
43puth gle c 14 2
44ret 0
45end