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 / qualification / om2 / sec / s3s4 / rot-trap-om1.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note OM-1 twin of rot-trap.om (contract section 3 lines 79-81) for the pinned compiler 734f0a39: the |
| 3 | note rotations are the OM-1 shift helpers tr*/tl* (n = 0 returns x, else shr/shl by n first), so |
| 4 | note every selector A-O reaches an OM-1 shift by n >= w, which traps 7 (OMEGESE 9.3): exit 107, no |
| 5 | note stdout. P prints rotr uint 4041331395 by 31. Same expectations as the OM-2 unit. |
| 6 | note (this line replaces the om2 line, so the line numbers equal those of rot-trap.om) |
| 7 | note OM-1 unit |
| 8 | fn rr8 x uchar n uchar to uchar |
| 9 | ret tr8 x n |
| 10 | end |
| 11 | fn rl8 x uchar n uchar to uchar |
| 12 | ret tl8 x n |
| 13 | end |
| 14 | fn rr16 x ushort n ushort to ushort |
| 15 | ret tr16 x n |
| 16 | end |
| 17 | fn rl16 x ushort n ushort to ushort |
| 18 | ret tl16 x n |
| 19 | end |
| 20 | fn rr32 x uint n uint to uint |
| 21 | ret tr32 x n |
| 22 | end |
| 23 | fn rl32 x uint n uint to uint |
| 24 | ret tl32 x n |
| 25 | end |
| 26 | fn rr64 x ulong n ulong to ulong |
| 27 | ret tr64 x n |
| 28 | end |
| 29 | fn rl64 x ulong n ulong to ulong |
| 30 | ret tl64 x n |
| 31 | end |
| 32 | fn main to int |
| 33 | s = new uchar 1 0 |
| 34 | r = read 0 s 0 1 |
| 35 | k = get s 0 |
| 36 | a = uchar 177 |
| 37 | b = ushort 45508 |
| 38 | c = uint 4041331395 |
| 39 | d = ulong 9305357566071262703 |
| 40 | if eq k 65 |
| 41 | pu ulong tr8 a 8 |
| 42 | end |
| 43 | if eq k 66 |
| 44 | pu ulong tl16 b 16 |
| 45 | end |
| 46 | if eq k 67 |
| 47 | pu ulong tr32 c 32 |
| 48 | end |
| 49 | if eq k 68 |
| 50 | pu tl64 d 64 |
| 51 | end |
| 52 | if eq k 69 |
| 53 | pu ulong rl8 a 8 |
| 54 | end |
| 55 | if eq k 70 |
| 56 | pu ulong rr16 b 16 |
| 57 | end |
| 58 | if eq k 71 |
| 59 | pu ulong rl32 c 32 |
| 60 | end |
| 61 | if eq k 72 |
| 62 | pu rr64 d 64 |
| 63 | end |
| 64 | if eq k 73 |
| 65 | pu ulong rr8 a 9 |
| 66 | end |
| 67 | if eq k 74 |
| 68 | pu ulong rl16 b 65535 |
| 69 | end |
| 70 | if eq k 75 |
| 71 | pu ulong rr32 c 4294967295 |
| 72 | end |
| 73 | if eq k 76 |
| 74 | pu rl64 d 18446744073709551615 |
| 75 | end |
| 76 | if eq k 77 |
| 77 | pu ulong tr32 c 33 |
| 78 | end |
| 79 | if eq k 78 |
| 80 | pu tl64 d 65 |
| 81 | end |
| 82 | if eq k 79 |
| 83 | pu ulong tl8 a 255 |
| 84 | end |
| 85 | if eq k 80 |
| 86 | pu ulong tr32 c 31 |
| 87 | end |
| 88 | ret 0 |
| 89 | end |
| 90 | fn tr8 x uchar n uchar to uchar |
| 91 | if eq n 0 |
| 92 | ret x |
| 93 | end |
| 94 | ret or shr x n shl x sub 8 n |
| 95 | end |
| 96 | fn tl8 x uchar n uchar to uchar |
| 97 | if eq n 0 |
| 98 | ret x |
| 99 | end |
| 100 | ret or shl x n shr x sub 8 n |
| 101 | end |
| 102 | fn tr16 x ushort n ushort to ushort |
| 103 | if eq n 0 |
| 104 | ret x |
| 105 | end |
| 106 | ret or shr x n shl x sub 16 n |
| 107 | end |
| 108 | fn tl16 x ushort n ushort to ushort |
| 109 | if eq n 0 |
| 110 | ret x |
| 111 | end |
| 112 | ret or shl x n shr x sub 16 n |
| 113 | end |
| 114 | fn tr32 x uint n uint to uint |
| 115 | if eq n 0 |
| 116 | ret x |
| 117 | end |
| 118 | ret or shr x n shl x sub 32 n |
| 119 | end |
| 120 | fn tl32 x uint n uint to uint |
| 121 | if eq n 0 |
| 122 | ret x |
| 123 | end |
| 124 | ret or shl x n shr x sub 32 n |
| 125 | end |
| 126 | fn tr64 x ulong n ulong to ulong |
| 127 | if eq n 0 |
| 128 | ret x |
| 129 | end |
| 130 | ret or shr x n shl x sub 64 n |
| 131 | end |
| 132 | fn tl64 x ulong n ulong to ulong |
| 133 | if eq n 0 |
| 134 | ret x |
| 135 | end |
| 136 | ret or shl x n shr x sub 64 n |
| 137 | end |