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