interplane.Get Omega
Read in your language

sovereign-intelligence

Front door to Drake Stapleton's sovereign stack.

Brought by drakestapleton

branch main Branches Tags History

sovereign-intelligence / harness / examples / text.om

48 lines · 1111 bytes Raw Blame History
1note text: escapes are only backslash n, t, backslash and quote; len of a text is its byte count
2note ---- output helpers: a function works on a global by naming it (a global is never an argument)
3global ob uchar 32
4note outb: write ob[off .. off+n) to stdout; a short write continues, 0 or an error exits 90
5note bound: every pass writes at least one byte and n <= 32, so at most 32 passes
6fn outb off ulong n ulong to void
7e = add off n
8p = off
9while lt p e bound 32
10k = write 1 ob p sub e p
11if le k 0
12exit 90
13end
14p = add p ulong k
15end
16end
17note putu: v in decimal, then a newline. A ulong has at most 20 digits, so 20 passes
18fn putu v ulong to void
19i = ulong 31
20put ob 31 10
21n = v
22while true bound 20
23i = sub i 1
24put ob i uchar add rem n 10 48
25n = div n 10
26if eq n 0
27break
28end
29end
30outb i sub 32 i
31end
32note putl: a signed value; -(v+1)+1 avoids negating the minimum, which would trap 1
33fn putl v long to void
34if lt v 0
35put ob 0 45
36outb 0 1
37putu add ulong neg add v 1 1
38ret
39end
40putu ulong v
41end
42text t "tab\there \"q\" back\\slash\n"
43fn main to int
44k = write 1 t 0 len t
45putu len t
46putu ulong get t 0
47ret 0
48end