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 / gpu / nvidia / om / api / apish_trit.om

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