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
omega-mv / seed / helix / strand3_trickster / seedC0.c0
| 1 | % seedC0.c0 -- Rung C0 of Strand 3 ("The Trickster" -- Adversarial Chaos Strand). |
| 2 | % 3rd completely independent hand-written AArch64 W^X seed (404 bytes), zero shared grammar or layout |
| 3 | % with Strand A (seed0.hex, 0x400000, '#' comments, 32-bit LE words, RWX) or |
| 4 | % Strand B (seedB0.b0, 0x500000, ';' comments, byte pairs, x10..x14). |
| 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 11. Odd trailing nibble -> exit 12. Read error -> exit 13. Write error -> exit 14. |
| 9 | % Memory model: pure W^X (p_flags = PF_R|PF_X = 5, p_vaddr = 0x600000, p_memsz == p_filesz = 404). |
| 10 | % Distinct register allocation: x19=acc, x20=nibbles, x21=in_comment, x22=sp_buf, x23=10. |
| 11 | % Encodings verified against Arm Architecture Reference Manual DDI 0487. |
| 12 | |
| 13 | % ---- ELF-64 file header (64 bytes, 0x00..0x3f) ---- |
| 14 | 7f:45:4c:46:02:01:01:00 % e_ident[0..7] |
| 15 | 00:00:00:00:00:00:00:00 % e_ident[8..15] |
| 16 | 02:00:b7:00:01:00:00:00 % ET_EXEC, EM_AARCH64, version 1 |
| 17 | 78:00:60:00:00:00:00:00 % e_entry = 0x600078 |
| 18 | 40:00:00:00:00:00:00:00 % e_phoff = 64 |
| 19 | 00:00:00:00:00:00:00:00 % e_shoff = 0 |
| 20 | 00:00:00:00:40:00:38:00 % e_flags=0, ehsize=64, phentsize=56 |
| 21 | 01:00:00:00:00:00:00:00 % phnum=1 |
| 22 | |
| 23 | % ---- ELF-64 program header (56 bytes, 0x40..0x77) ---- |
| 24 | 01:00:00:00:05:00:00:00 % PT_LOAD, PF_R|PF_X = 5 (pure W^X!) |
| 25 | 00:00:00:00:00:00:00:00 % p_offset = 0 |
| 26 | 00:00:60:00:00:00:00:00 % p_vaddr = 0x600000 |
| 27 | 00:00:60:00:00:00:00:00 % p_paddr = 0x600000 |
| 28 | 94:01:00:00:00:00:00:00 % p_filesz = 404 (0x194 = 120 header + 71*4 code) |
| 29 | 94:01:00:00:00:00:00:00 % p_memsz = 404 (zero BSS) |
| 30 | 00:10:00:00:00:00:00:00 % p_align = 4096 |
| 31 | |
| 32 | % ---- AArch64 code (71 instructions, 284 bytes, 0x600078..0x600193) ---- |
| 33 | % Registers: x19=acc, x20=nibble_cnt, x21=in_comment, x22=sp_buf, x23=10 |
| 34 | ff:43:00:d1 % [0] sub sp, sp, #16 |
| 35 | f6:03:00:91 % [1] mov x22, sp |
| 36 | 13:00:80:d2 % [2] movz x19, #0 |
| 37 | 14:00:80:d2 % [3] movz x20, #0 |
| 38 | 15:00:80:d2 % [4] movz x21, #0 |
| 39 | 57:01:80:d2 % [5] movz x23, #10 |
| 40 | |
| 41 | % loop [6]: SYS_read(0, x22, 1) |
| 42 | 00:00:80:d2 % [6] movz x0, #0 |
| 43 | e1:03:16:aa % [7] mov x1, x22 (orr x1, xzr, x22) |
| 44 | 22:00:80:d2 % [8] movz x2, #1 |
| 45 | e8:07:80:d2 % [9] movz x8, #63 |
| 46 | 01:00:00:d4 % [10] svc #0 |
| 47 | 1f:00:00:f1 % [11] subs xzr, x0, #0 |
| 48 | 40:06:00:54 % [12] b.eq +50 -> [62] eof |
| 49 | ab:06:00:54 % [13] b.lt +53 -> [66] err_read |
| 50 | c0:02:40:39 % [14] ldrb w0, [x22] |
| 51 | b5:00:00:b4 % [15] cbz x21, +5 -> [20] |
| 52 | |
| 53 | % inside '%' comment [16..19] |
| 54 | 1f:28:00:71 % [16] subs wzr, w0, #10 ('\n') |
| 55 | a1:fe:ff:54 % [17] b.ne -11 -> [6] |
| 56 | 15:00:80:d2 % [18] movz x21, #0 |
| 57 | f3:ff:ff:17 % [19] b -13 -> [6] |
| 58 | |
| 59 | % not in comment [20..23]: check '%' (37 = 0x25) |
| 60 | 1f:94:00:71 % [20] subs wzr, w0, #37 ('%') |
| 61 | 61:00:00:54 % [21] b.ne +3 -> [24] |
| 62 | 35:00:80:d2 % [22] movz x21, #1 |
| 63 | ef:ff:ff:17 % [23] b -17 -> [6] |
| 64 | |
| 65 | % digits '0'..'9' [24..26] |
| 66 | 01:c0:00:71 % [24] subs w1, w0, #48 |
| 67 | 3f:28:00:71 % [25] subs wzr, w1, #10 |
| 68 | 83:02:00:54 % [26] b.lo +20 -> [46] got_nib |
| 69 | |
| 70 | % lowercase 'a'..'f' [27..29] |
| 71 | 01:84:01:71 % [27] subs w1, w0, #97 |
| 72 | 3f:18:00:71 % [28] subs wzr, w1, #6 |
| 73 | 03:02:00:54 % [29] b.lo +16 -> [45] got_hex |
| 74 | |
| 75 | % uppercase 'A'..'F' [30..32] |
| 76 | 01:04:01:71 % [30] subs w1, w0, #65 |
| 77 | 3f:18:00:71 % [31] subs wzr, w1, #6 |
| 78 | a3:01:00:54 % [32] b.lo +13 -> [45] got_hex |
| 79 | |
| 80 | % separators: ':' (58), space (32), LF (10), TAB (9), CR (13) [33..42] |
| 81 | 1f:e8:00:71 % [33] subs wzr, w0, #58 (':') |
| 82 | 80:fc:ff:54 % [34] b.eq -28 -> [6] |
| 83 | 1f:80:00:71 % [35] subs wzr, w0, #32 (' ') |
| 84 | 40:fc:ff:54 % [36] b.eq -30 -> [6] |
| 85 | 1f:28:00:71 % [37] subs wzr, w0, #10 ('\n') |
| 86 | 00:fc:ff:54 % [38] b.eq -32 -> [6] |
| 87 | 1f:24:00:71 % [39] subs wzr, w0, #9 ('\t') |
| 88 | c0:fb:ff:54 % [40] b.eq -34 -> [6] |
| 89 | 1f:34:00:71 % [41] subs wzr, w0, #13 ('\r') |
| 90 | 80:fb:ff:54 % [42] b.eq -36 -> [6] |
| 91 | |
| 92 | % invalid char -> exit 11 [43..44] |
| 93 | 60:01:80:d2 % [43] movz x0, #11 |
| 94 | 19:00:00:14 % [44] b +25 -> [69] do_exit |
| 95 | |
| 96 | % accumulate nibble [45..50] |
| 97 | 21:00:17:0b % [45] add w1, w1, w23 (+10) |
| 98 | 73:6e:1c:53 % [46] lsl w19, w19, #4 |
| 99 | 73:02:01:2a % [47] orr w19, w19, w1 |
| 100 | 94:06:00:91 % [48] add x20, x20, #1 |
| 101 | 9f:0a:00:f1 % [49] subs xzr, x20, #2 |
| 102 | 81:fa:ff:54 % [50] b.ne -44 -> [6] |
| 103 | |
| 104 | % emit byte [51..61] |
| 105 | d3:02:00:39 % [51] strb w19, [x22] |
| 106 | 20:00:80:d2 % [52] movz x0, #1 |
| 107 | e1:03:16:aa % [53] mov x1, x22 |
| 108 | 22:00:80:d2 % [54] movz x2, #1 |
| 109 | 08:08:80:d2 % [55] movz x8, #64 (SYS_write) |
| 110 | 01:00:00:d4 % [56] svc #0 |
| 111 | 1f:04:00:f1 % [57] subs xzr, x0, #1 |
| 112 | 41:01:00:54 % [58] b.ne +10 -> [68] err_write |
| 113 | 13:00:80:d2 % [59] movz x19, #0 |
| 114 | 14:00:80:d2 % [60] movz x20, #0 |
| 115 | c9:ff:ff:17 % [61] b -55 -> [6] |
| 116 | |
| 117 | % eof [62..65] |
| 118 | 00:00:80:d2 % [62] movz x0, #0 |
| 119 | d4:00:00:b4 % [63] cbz x20, +6 -> [69] do_exit |
| 120 | 80:01:80:d2 % [64] movz x0, #12 (odd nibble) |
| 121 | 04:00:00:14 % [65] b +4 -> [69] do_exit |
| 122 | |
| 123 | % err_read [66..67] |
| 124 | a0:01:80:d2 % [66] movz x0, #13 |
| 125 | 02:00:00:14 % [67] b +2 -> [69] do_exit |
| 126 | |
| 127 | % err_write [68] |
| 128 | c0:01:80:d2 % [68] movz x0, #14 |
| 129 | |
| 130 | % do_exit [69..70] |
| 131 | a8:0b:80:d2 % [69] movz x8, #93 (SYS_exit) |
| 132 | 01:00:00:d4 % [70] svc #0 |