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 / gpu / nvidia / om / api / apish_trit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Sixteen int8 trits, passed as bytes. 1, 0 and 255 (int8 -1) encode to 1, 0, 2. |
| 3 | note Any other byte returns bit 32 set. A legal word stays below 2^32. |
| 4 | |
| 5 | fn apishr v view uchar 16 to ulong |
| 6 | word = ulong 0 |
| 7 | for i ulong 16 |
| 8 | b = get v i |
| 9 | code = uint 3 |
| 10 | if eq b 1 |
| 11 | code = 1 |
| 12 | end |
| 13 | if eq b 255 |
| 14 | code = 2 |
| 15 | end |
| 16 | if eq b 0 |
| 17 | code = 0 |
| 18 | end |
| 19 | if eq code 3 |
| 20 | ret shl ulong 1 32 |
| 21 | end |
| 22 | word = or word shl ulong code mul i 2 |
| 23 | end |
| 24 | ret word |
| 25 | end |