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 / equiv / rot.unit.om

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