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 / omc / tests / a64-decode-cases.om
| 1 | om2 |
| 2 | note Deterministic parity input for seed/check/a64check.om and the retained C reference. |
| 3 | note 65536 xorshift words plus every one-bit flip of every decoder pattern, then 4096 low-register |
| 4 | note and immediate variations per pattern. Constants are the C reference's pattern words, not a new ISA. |
| 5 | text hx "0123456789abcdef" |
| 6 | global outb uchar 65536 |
| 7 | global outn ulong 1 |
| 8 | fn flush to void |
| 9 | p = ulong 0 |
| 10 | while lt p get outn 0 bound 65536 |
| 11 | r = write 1 outb p sub get outn 0 p |
| 12 | if le r 0 |
| 13 | exit 2 |
| 14 | end |
| 15 | p = add p ulong r |
| 16 | end |
| 17 | put outn 0 0 |
| 18 | end |
| 19 | fn emit w uint to void |
| 20 | if gt get outn 0 65527 |
| 21 | flush |
| 22 | end |
| 23 | p = get outn 0 |
| 24 | for j ulong 8 |
| 25 | v = and shr ulong w sub 28 mul j 4 15 |
| 26 | put outb add p j get hx v |
| 27 | end |
| 28 | put outb add p 8 10 |
| 29 | put outn 0 add p 9 |
| 30 | end |
| 31 | fn pattern i ulong to uint |
| 32 | if eq i 0 |
| 33 | ret 0xd65f03c0 |
| 34 | end |
| 35 | if eq i 1 |
| 36 | ret 0x14000000 |
| 37 | end |
| 38 | if eq i 2 |
| 39 | ret 0x54000000 |
| 40 | end |
| 41 | if eq i 3 |
| 42 | ret 0x34000000 |
| 43 | end |
| 44 | if eq i 4 |
| 45 | ret 0x35000000 |
| 46 | end |
| 47 | if eq i 5 |
| 48 | ret 0x52800000 |
| 49 | end |
| 50 | if eq i 6 |
| 51 | ret 0x1b007c00 |
| 52 | end |
| 53 | if eq i 7 |
| 54 | ret 0x0a000000 |
| 55 | end |
| 56 | if eq i 8 |
| 57 | ret 0x2a000000 |
| 58 | end |
| 59 | if eq i 9 |
| 60 | ret 0x4a000000 |
| 61 | end |
| 62 | if eq i 10 |
| 63 | ret 0x0b000000 |
| 64 | end |
| 65 | if eq i 11 |
| 66 | ret 0x4b000000 |
| 67 | end |
| 68 | if eq i 12 |
| 69 | ret 0x72800000 |
| 70 | end |
| 71 | if eq i 13 |
| 72 | ret 0x10000000 |
| 73 | end |
| 74 | if eq i 14 |
| 75 | ret 0xb9400000 |
| 76 | end |
| 77 | if eq i 15 |
| 78 | ret 0xb9000000 |
| 79 | end |
| 80 | if eq i 16 |
| 81 | ret 0xb8400400 |
| 82 | end |
| 83 | if eq i 17 |
| 84 | ret 0xb8000400 |
| 85 | end |
| 86 | if eq i 18 |
| 87 | ret 0x39400000 |
| 88 | end |
| 89 | if eq i 19 |
| 90 | ret 0x39000000 |
| 91 | end |
| 92 | if eq i 20 |
| 93 | ret 0x71000000 |
| 94 | end |
| 95 | ret 0x6b000000 |
| 96 | end |
| 97 | fn main to int |
| 98 | x = uint 1077 |
| 99 | for i ulong 65536 |
| 100 | x = xor x shl x 13 |
| 101 | x = xor x shr x 17 |
| 102 | x = xor x shl x 5 |
| 103 | emit x |
| 104 | end |
| 105 | for i ulong 22 |
| 106 | b = pattern i |
| 107 | for j uint 32 |
| 108 | emit xor b shl uint 1 j |
| 109 | end |
| 110 | for k uint 4096 |
| 111 | emit or b or shl and k 31 16 and k 1023 |
| 112 | emit or or b 0x80000000 shl k 5 |
| 113 | end |
| 114 | end |
| 115 | flush |
| 116 | ret 0 |
| 117 | end |