interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / v2 / lay.om

45 lines · 903 bytes Raw Blame History
1note lay.om: an OM-2 unit for the native ABI v2 tests (tests/native/v2/run.sh): a layout parameter and
2note out parameters.
3note bridge c-type blk lay_blk
4note bridge c-define LAY_TAG_SIZE 8
5om2
6layout blk 24
7field a uint at 0 little
8field n ulong at 8 little
9field tag uchar 8 at 16 little
10end
11export fn absorb c edit blk d view uchar * to void
12s = get c a
13for i ulong len d
14s = add s uint get d i
15end
16put c a s
17put c n add get c n len d
18end
19export fn digest c view blk o out uchar 16 to ulong
20for i ulong 8
21put o i get c tag i
22end
23x = get c a
24for i ulong 4
25put o add 8 i uchar and x 255
26x = shr x 8
27end
28ret get c n
29end
30export fn swap8 d view uchar * o out uchar 8 to ulong
31for i ulong 8
32put o i get d sub 7 i
33end
34ret len d
35end
36export fn halt o out ulong 2 to void
37put o 0 7
38trap 9
39end
40export fn two a out uchar 4 b out uchar 4 to void
41for i ulong 4
42put a i uchar add i 1
43put b i uchar add i 5
44end
45end