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 / equiv / rot.unit.om
| 1 | note irequiv fixture (issue 826): rotate a byte right, traps included. |
| 2 | note r8 is copied verbatim from seed/omc/om2/s1/rot.om line 21 (omega-mv 62d1d0d6); |
| 3 | note for n >= 8 its shr traps 7 (amount at or above the width). |
| 4 | note r8w is a refactor through a doubled ushort, keeping that trap explicitly. |
| 5 | note r8m is a deliberate mutant that masks n with 7: same values for n < 8, but |
| 6 | note a value instead of trap 7 for every n >= 8. |
| 7 | fn r8 x uchar n uchar to uchar |
| 8 | if eq n 0 |
| 9 | ret x |
| 10 | end |
| 11 | ret or shr x n shl x sub 8 n |
| 12 | end |
| 13 | fn r8w x uchar n uchar to uchar |
| 14 | if ge n 8 |
| 15 | trap 7 |
| 16 | end |
| 17 | d = or shl ushort x 8 ushort x |
| 18 | e = and shr d ushort n 255 |
| 19 | ret uchar e |
| 20 | end |
| 21 | fn r8m x uchar n uchar to uchar |
| 22 | k = and n 7 |
| 23 | if eq k 0 |
| 24 | ret x |
| 25 | end |
| 26 | ret or shr x k shl x sub 8 k |
| 27 | end |