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 / seed / omc / tests / pools / g3.om

73 lines · 1413 bytes Raw Blame History
1note gate-pools 3: enlarge runs inside the value of put, the index of get, and the counts of read and
2note write; every call grows the pool it serves by 4096 elements and a blocker pool beside it, so mremap
3note moves the regions and later mappings reuse the old addresses (the gate counts both with strace).
4note stdin: the 40 bytes abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN.
5global P ulong *
6global Q ulong *
7global U uchar *
8global V uchar *
9global ob uchar 24
10fn pnum v ulong to void
11put ob 23 10
12i = ulong 23
13x = v
14go = true
15while go bound 21
16i = sub i 1
17put ob i uchar add rem x 10 48
18x = div x 10
19go = ne x 0
20end
21k = write 1 ob i sub 24 i
22end
23fn plong v long to void
24if lt v 0
25put ob 0 uchar 45
26k = write 1 ob 0 1
27pnum ulong neg v
28else
29pnum ulong v
30end
31end
32fn gv v ulong to ulong
33r = enlarge P add len P 4096
34r = enlarge Q add len Q 4096
35ret v
36end
37fn gi j ulong to ulong
38r = enlarge P add len P 4096
39r = enlarge Q add len Q 4096
40ret j
41end
42fn gu n ulong to ulong
43r = enlarge U add len U 4096
44r = enlarge V add len V 4096
45ret n
46end
47fn main to int
48r = enlarge Q ulong 1
49r = enlarge P ulong 1
50r = enlarge V ulong 1
51r = enlarge U ulong 64
52j = ulong 0
53while lt j 40
54put P j gv add mul j 3 1
55x = get P gi j
56pnum x
57k = read 0 U j gu 1
58k = write 1 U j gu 1
59pnum ulong k
60j = add j 1
61end
62k = write 1 U 0 40
63s = ulong 0
64j = ulong 0
65while lt j 40
66s = add s get P j
67j = add j 1
68end
69pnum s
70pnum len P
71pnum len U
72ret 0
73end