interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / omega-reference / vendor / examples / om2_hex_rotr.om

40 lines · 869 bytes Raw Blame History
1note om2_hex_rotr: the first line that is not blank or a note opts in to OM-2: hex literals and rotr
2om2
3note ---- OM-2 output helpers: an unsized view parameter takes an array or text of any length
4note outv: write all of a to stdout; a short write continues, 0 or an error exits 90
5fn outv a view uchar * to void
6e = len a
7p = ulong 0
8while lt p e bound 65536
9k = write 1 a p sub e p
10if le k 0
11exit 90
12end
13p = add p ulong k
14end
15end
16note putu: v in decimal, then a newline
17note a part of a global is error 19, so the digits go in a local array
18fn putu v ulong to void
19b = new uchar 21 0
20i = ulong 20
21put b 20 10
22n = v
23while true bound 20
24i = sub i 1
25put b i uchar add rem n 10 48
26n = div n 10
27if eq n 0
28break
29end
30end
31outv part b i sub 21 i
32end
33fn main to int
34x = uint 0xdeadbeef
35putu ulong x
36putu ulong rotr x 8
37putu 0xffffffffffffffff
38putu ulong and x 0xff
39ret 0
40end