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 / native / omega / allen / base.om

102 lines · 1495 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