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 / bitrev.unit.om
| 1 | note irequiv fixture (issue 826): reverse the bits of a byte. |
| 2 | note bitrev8 is copied verbatim from tests/one_layer/omegese/dev/dev09.omegese |
| 3 | note (omega-mv 62d1d0d6). bitrev8s is a refactor: a three-stage swap network. |
| 4 | fn bitrev8 x uchar to uchar |
| 5 | r = uchar 0 |
| 6 | for i uint 8 |
| 7 | r = shl r 1 |
| 8 | b = and x 1 |
| 9 | r = or r b |
| 10 | x = shr x 1 |
| 11 | end |
| 12 | ret r |
| 13 | end |
| 14 | fn bitrev8s x uchar to uchar |
| 15 | x = or shr and x 240 4 shl and x 15 4 |
| 16 | x = or shr and x 204 2 shl and x 51 2 |
| 17 | ret or shr and x 170 1 shl and x 85 1 |
| 18 | end |