interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / native / omegese45 / translate / otio.om

85 lines · 1649 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note otio: byte I/O helpers shared by the #45 translator units (prefix ot).
3note Output is collected in otob and written once by otflush, so a refusal
4note never leaves a partial success line on stdout. Fixed texts are emitted
5note by otfrag.om (concatenated after the tool file that defines otfr).
6global otob uchar 8192
7global otol ulong 1
8global otin uchar 1024
9global otinl ulong 1
10global otdb uchar 24
11
12note Read all of fd 0 into otin. Returns the byte count, -1 when the input
13note does not fit (1024 bytes or more), -2 on a read error. Every pass adds
14note at least one byte, so 1024 passes bound the loop.
15fn otrdin to long
16put otinl 0 0
17n = ulong 0
18while true bound 1025
19if ge n 1024
20ret neg long 1
21end
22k = read 0 otin n sub 1024 n
23if lt k 0
24ret neg long 2
25end
26if eq k 0
27put otinl 0 n
28ret long n
29end
30n = add n ulong k
31end
32ret neg long 2
33end
34
35fn otpb c uchar to void
36o = get otol 0
37put otob o c
38put otol 0 add o 1
39end
40
41note Append decimal v.
42fn otpdec v ulong to void
43if eq v 0
44otpb 48
45ret
46end
47p = ulong 24
48while gt v 0 bound 24
49p = sub p 1
50put otdb p uchar add 48 rem v 10
51v = div v 10
52end
53while lt p 24 bound 24
54otpb get otdb p
55p = add p 1
56end
57end
58
59note Append v as exactly nd lowercase hex digits (nd 1..16).
60fn otphex v ulong nd ulong to void
61i = nd
62while gt i 0 bound 16
63i = sub i 1
64d = and shr v mul i 4 15
65if lt d 10
66otpb uchar add d 48
67else
68otpb uchar add d 87
69end
70end
71end
72
73note Write otob to fd 1. A short or failed write exits 2.
74fn otflush to void
75n = get otol 0
76o = ulong 0
77while lt o n bound 8193
78w = write 1 otob o sub n o
79if le w 0
80exit 2
81end
82o = add o ulong w
83end
84put otol 0 0
85end