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 / physics0 / request.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Binary request adapter for the native stream consumer, also exercised by unit.om. |
| 3 | global rngreq uchar 265 |
| 4 | global rngout uchar 64 |
| 5 | |
| 6 | fn rngreqok n ulong to int |
| 7 | if or lt n 8 gt n 264 |
| 8 | ret 2 |
| 9 | end |
| 10 | seed = ulong 0 |
| 11 | for i ulong 8 |
| 12 | seed = or seed shl ulong get rngreq i mul i 8 |
| 13 | end |
| 14 | size = sub n 8 |
| 15 | for i ulong size |
| 16 | put rngtag i get rngreq add i 8 |
| 17 | end |
| 18 | ret rnginit seed size |
| 19 | end |
| 20 | |
| 21 | fn rngpack to void |
| 22 | for word ulong 8 |
| 23 | v = rngnext |
| 24 | for octet ulong 8 |
| 25 | put rngout add mul word 8 octet uchar and shr v mul octet 8 255 |
| 26 | end |
| 27 | end |
| 28 | ret |
| 29 | end |