interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / evidence / allen-omega-L694 / runtime-red.om

198 lines · 3380 bytes Raw Blame History
1note L694 fixed-buffer utilities. No platform effects in product functions.
2global In uchar 8192
3global Inlen ulong 1
4global Outb uchar 8192
5global Outlen ulong 1
6global Err ulong 1
7text Digits "0123456789abcdef"
8fn emitb c uchar to void
9n = get Outlen 0
10if ge n len Outb
11put Err 0 1
12else
13put Outb n c
14put Outlen 0 add n 1
15end
16end
17fn emitn v ulong to void
18d = new uchar 20 0
19n = ulong 0
20x = v
21put d n uchar add rem x 10 48
22n = add n 1
23x = div x 10
24while gt x 0
25put d n uchar add rem x 10 48
26n = add n 1
27x = div x 10
28end
29while gt n 0
30n = sub n 1
31emitb get d n
32end
33end
34fn outreset to void
35put Outlen 0 0
36put Err 0 0
37end
38fn ineq at ulong c uchar to bool
39if ge at get Inlen 0
40ret false
41end
42ret eq get In at c
43end
44fn isdigit c uchar to bool
45ret and ge c 48 le c 57
46end
47note Parser cursor P0, number P1, error P2. Never wraps a u32.
48global P ulong 3
49fn number to void
50v = ulong 0
51n = ulong 0
52p = get P 0
53while lt p get Inlen 0
54c = get In p
55if not isdigit c
56put P 0 p
57put P 1 v
58if eq n 0
59put P 2 1
60end
61ret
62end
63if or ge n 10 gt v 429496729
64put P 2 1
65ret
66end
67v = add mul v 10 sub ulong c 48
68if gt v 4294967295
69put P 2 1
70ret
71end
72n = add n 1
73p = add p 1
74end
75put P 0 p
76put P 1 v
77if eq n 0
78put P 2 1
79end
80end
81fn expect c uchar to void
82p = get P 0
83if not ineq p c
84put P 2 1
85else
86put P 0 add p 1
87end
88end
89fn crc off ulong count ulong to uint
90c = uint 4294967295
91for i ulong count
92c = xor c uint get In add off i
93for k ulong 8
94if ne and c 1 0
95c = xor shr c 1 3988292384
96else
97c = shr c 1
98end
99end
100end
101ret not c
102end
103note R: seq, active, kind (1 chat 2 code 3 more), asked, heard, slow,
104note code-visible, prompt length, answer length, history count, session.
105global R ulong 16
106global Prompt uchar 160
107global Answer uchar 160
108global Hist uchar 5120
109global Hlen ulong 32
110text Ack "I need to code that. Let me send it off to the Spark."
111text Ackmore "Let me take that change to the Spark."
112fn start kind ulong now ulong to bool
113ret false
114end
115fn answer seq ulong now ulong to bool
116ret false
117end
118fn cancel to void
119end
120fn tick now ulong to ulong
121ret 0
122end
123fn reset to void
124end
125global Fails ulong 1
126global Checks ulong 1
127fn check ok bool id ulong to void
128put Checks 0 add get Checks 0 1
129outreset
130emitn id
131if ok
132emitb 32
133emitb 48
134else
135put Fails 0 add get Fails 0 1
136emitb 32
137emitb 49
138end
139emitb 10
140w = write 1 Outb 0 get Outlen 0
141end
142text Ask "make me a calculator"
143text Reply "Model supplied answer."
144fn askload to void
145put Inlen 0 len Ask
146for i ulong len Ask
147put In i get Ask i
148end
149end
150fn main to int
151askload
152check start 2 0 1
153check eq get R 1 1 2
154check eq get R 2 2 3
155check eq get R 8 len Ack 4
156old = get R 0
157check not start 1 1 5
158put Inlen 0 len Reply
159for i ulong len Reply
160put In i get Reply i
161end
162check not answer add old 1 2 6
163check eq get R 8 len Ack 7
164check answer old 3 8
165check eq get R 1 0 9
166askload
167check start 1 4 10
168check gt get R 0 old 11
169cancel
170check eq get R 1 0 12
171check not answer get R 0 5 13
172askload
173check start 1 10 14
174check eq tick 20009 0 15
175check eq tick 20010 1 16
176check eq tick 20011 0 17
177check eq tick 30010 2 18
178check eq get R 1 0 19
179old = get R 0
180reset
181check eq get R 0 old 20
182askload
183check start 2 40000 21
184check gt get R 0 old 22
185cancel
186put Inlen 0 160
187check not start 1 40001 23
188check eq get R 1 0 24
189askload
190check not start 3 40002 25
191put R 6 1
192check start 3 40003 26
193check eq get R 8 len Ackmore 27
194cancel
195put R 0 4294967295
196check not start 1 40004 28
197ret int get Fails 0
198end