interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / character-codes.wiki

58 lines · 1098 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text sp " "
8text ch "a"
9note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10fn emit a view uchar * to void
11o = ulong 0
12while lt o len a bound 4096
13k = write 1 a o sub len a o
14if le k 0
15exit 1
16end
17o = add o ulong k
18end
19end
20note emitu writes n in decimal; 20 digits hold every ulong
21fn emitu n ulong to void
22d = new uchar 20 0
23i = ulong 20
24v = n
25while true bound 20
26i = sub i 1
27put d i uchar add rem v 10 48
28v = div v 10
29if eq v 0
30break
31end
32end
33emit part d i sub 20 i
34end
35note emitc writes one byte
36fn emitc c uchar to void
37b = new uchar 1 0
38put b 0 c
39emit b
40end
41fn main to int
42note a byte is a number: the code of a is get ch 0, and the number 97 printed as a byte is a
43emit ch
44emit sp
45emitu ulong get ch 0
46emit nl
47emitu 97
48emit sp
49emitc 97
50emit nl
51ret 0
52end
53</syntaxhighlight>
54{{out}}
55<pre>
56a 97
5797 a
58</pre>