interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / helix / strand4_ascetic / seedD0.d0

131 lines · 4899 bytes Raw Blame History
1! seedD0.d0 -- Rung D0 of Strand 4 ("The Ascetic" -- Energy & Thermal Strand).
2! 4th completely independent hand-written AArch64 W^X seed (404 bytes), zero shared grammar or layout
3! with Strand A (seed0.hex, 0x400000, '#'), Strand B (seedB0.b0, 0x500000, ';'), or
4! Strand C (seedC0.c0, 0x600000, '%' & ':').
5!
6! Grammar: '!' starts a comment to end of line. Every two hex digits emit one raw byte to stdout.
7! Whitespace (space, tab, CR, LF) and ',' separators are ignored.
8! Bad char -> exit 21. Odd trailing nibble -> exit 22. Read error -> exit 23. Write error -> exit 24.
9! Memory model: pure W^X (p_flags = PF_R|PF_X = 5, p_vaddr = 0x700000, p_memsz == p_filesz = 404).
10! Distinct register allocation: x24=acc, x25=nibble_cnt, x26=in_comment, x27=sp_buf, x28=10.
11
12! ---- ELF-64 file header (64 bytes, 0x00..0x3f) ----
137f,45,4c,46,02,01,01,00 ! e_ident[0..7]
1400,00,00,00,00,00,00,00 ! e_ident[8..15]
1502,00,b7,00,01,00,00,00 ! ET_EXEC, EM_AARCH64, version 1
1678,00,70,00,00,00,00,00 ! e_entry = 0x700078
1740,00,00,00,00,00,00,00 ! e_phoff = 64
1800,00,00,00,00,00,00,00 ! e_shoff = 0
1900,00,00,00,40,00,38,00 ! e_flags=0, ehsize=64, phentsize=56
2001,00,00,00,00,00,00,00 ! phnum=1
21
22! ---- ELF-64 program header (56 bytes, 0x40..0x77) ----
2301,00,00,00,05,00,00,00 ! PT_LOAD, PF_R|PF_X = 5 (pure W^X!)
2400,00,00,00,00,00,00,00 ! p_offset = 0
2500,00,70,00,00,00,00,00 ! p_vaddr = 0x700000
2600,00,70,00,00,00,00,00 ! p_paddr = 0x700000
2794,01,00,00,00,00,00,00 ! p_filesz = 404 (0x194 = 120 header + 71*4 code)
2894,01,00,00,00,00,00,00 ! p_memsz = 404 (zero BSS)
2900,10,00,00,00,00,00,00 ! p_align = 4096
30
31! ---- AArch64 code (71 instructions, 284 bytes, 0x700078..0x700193) ----
32! Registers: x24=acc, x25=nibble_cnt, x26=in_comment, x27=sp_buf, x28=10
33ff,43,00,d1 ! [0] sub sp, sp, #16
34fb,03,00,91 ! [1] mov x27, sp
3518,00,80,d2 ! [2] movz x24, #0
3619,00,80,d2 ! [3] movz x25, #0
371a,00,80,d2 ! [4] movz x26, #0
385c,01,80,d2 ! [5] movz x28, #10
39
40! loop [6]: SYS_read(0, x27, 1)
4100,00,80,d2 ! [6] movz x0, #0
42e1,03,1b,aa ! [7] mov x1, x27 (orr x1, xzr, x27)
4322,00,80,d2 ! [8] movz x2, #1
44e8,07,80,d2 ! [9] movz x8, #63
4501,00,00,d4 ! [10] svc #0
461f,00,00,f1 ! [11] subs xzr, x0, #0
4740,06,00,54 ! [12] b.eq +50 -> [62] eof
48ab,06,00,54 ! [13] b.lt +53 -> [66] err_read
4960,03,40,39 ! [14] ldrb w0, [x27]
50ba,00,00,b4 ! [15] cbz x26, +5 -> [20]
51
52! inside '!' comment [16..19]
531f,28,00,71 ! [16] subs wzr, w0, #10 ('\n')
54a1,fe,ff,54 ! [17] b.ne -11 -> [6]
551a,00,80,d2 ! [18] movz x26, #0
56f3,ff,ff,17 ! [19] b -13 -> [6]
57
58! not in comment [20..23]: check '!' (33 = 0x21)
591f,84,00,71 ! [20] subs wzr, w0, #33 ('!')
6061,00,00,54 ! [21] b.ne +3 -> [24]
613a,00,80,d2 ! [22] movz x26, #1
62ef,ff,ff,17 ! [23] b -17 -> [6]
63
64! digits '0'..'9' [24..26]
6501,c0,00,71 ! [24] subs w1, w0, #48
663f,28,00,71 ! [25] subs wzr, w1, #10
6783,02,00,54 ! [26] b.lo +20 -> [46] got_nib
68
69! lowercase 'a'..'f' [27..29]
7001,84,01,71 ! [27] subs w1, w0, #97
713f,18,00,71 ! [28] subs wzr, w1, #6
7203,02,00,54 ! [29] b.lo +16 -> [45] got_hex
73
74! uppercase 'A'..'F' [30..32]
7501,04,01,71 ! [30] subs w1, w0, #65
763f,18,00,71 ! [31] subs wzr, w1, #6
77a3,01,00,54 ! [32] b.lo +13 -> [45] got_hex
78
79! separators: ',' (44 = 0x2c), space (32), LF (10), TAB (9), CR (13) [33..42]
801f,b0,00,71 ! [33] subs wzr, w0, #44 (',')
8180,fc,ff,54 ! [34] b.eq -28 -> [6]
821f,80,00,71 ! [35] subs wzr, w0, #32 (' ')
8340,fc,ff,54 ! [36] b.eq -30 -> [6]
841f,28,00,71 ! [37] subs wzr, w0, #10 ('\n')
8500,fc,ff,54 ! [38] b.eq -32 -> [6]
861f,24,00,71 ! [39] subs wzr, w0, #9 ('\t')
87c0,fb,ff,54 ! [40] b.eq -34 -> [6]
881f,34,00,71 ! [41] subs wzr, w0, #13 ('\r')
8980,fb,ff,54 ! [42] b.eq -36 -> [6]
90
91! invalid char -> exit 21 [43..44]
92a0,02,80,d2 ! [43] movz x0, #21
9319,00,00,14 ! [44] b +25 -> [69] do_exit
94
95! accumulate nibble [45..50]
9621,00,1c,0b ! [45] add w1, w1, w28 (+10)
9718,6f,1c,53 ! [46] lsl w24, w24, #4
9818,03,01,2a ! [47] orr w24, w24, w1
9939,07,00,91 ! [48] add x25, x25, #1
1003f,0b,00,f1 ! [49] subs xzr, x25, #2
10181,fa,ff,54 ! [50] b.ne -44 -> [6]
102
103! emit byte [51..61]
10478,03,00,39 ! [51] strb w24, [x27]
10520,00,80,d2 ! [52] movz x0, #1
106e1,03,1b,aa ! [53] mov x1, x27
10722,00,80,d2 ! [54] movz x2, #1
10808,08,80,d2 ! [55] movz x8, #64 (SYS_write)
10901,00,00,d4 ! [56] svc #0
1101f,04,00,f1 ! [57] subs xzr, x0, #1
11141,01,00,54 ! [58] b.ne +10 -> [68] err_write
11218,00,80,d2 ! [59] movz x24, #0
11319,00,80,d2 ! [60] movz x25, #0
114c9,ff,ff,17 ! [61] b -55 -> [6]
115
116! eof [62..65]
11700,00,80,d2 ! [62] movz x0, #0
118d9,00,00,b4 ! [63] cbz x25, +6 -> [69] do_exit
119c0,02,80,d2 ! [64] movz x0, #22 (odd nibble)
12004,00,00,14 ! [65] b +4 -> [69] do_exit
121
122! err_read [66..67]
123e0,02,80,d2 ! [66] movz x0, #23
12402,00,00,14 ! [67] b +2 -> [69] do_exit
125
126! err_write [68]
12700,03,80,d2 ! [68] movz x0, #24
128
129! do_exit [69..70]
130a8,0b,80,d2 ! [69] movz x8, #93 (SYS_exit)
13101,00,00,d4 ! [70] svc #0