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