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 / protocol / omnet / om / quantity / oracle-export.om
| 1 | note Emit actual quantity outcomes for an independently implemented external oracle. |
| 2 | note Order width1..8, a0..cap, b0..cap, add/sub/mul. Record three LEu64: status,val,cap. |
| 3 | note Refusals retain sentinel17/19. No oracle arithmetic is used in this program. |
| 4 | global qxbuf uchar 24 |
| 5 | fn qxemit rc int out view qty to int |
| 6 | for k ulong 8 |
| 7 | put qxbuf k uchar and shr ulong rc mul k 8 255 |
| 8 | put qxbuf add k 8 uchar and shr get out val mul k 8 255 |
| 9 | put qxbuf add k 16 uchar and shr get out cap mul k 8 255 |
| 10 | end |
| 11 | p = ulong 0 |
| 12 | while lt p 24 |
| 13 | n = write 1 qxbuf p sub 24 p |
| 14 | if le n 0 |
| 15 | ret 2 |
| 16 | end |
| 17 | p = add p ulong n |
| 18 | end |
| 19 | ret 0 |
| 20 | end |
| 21 | fn main to int |
| 22 | out = new qty ulong 17 ulong 19 |
| 23 | a = new qty ulong 0 ulong 0 |
| 24 | b = new qty ulong 0 ulong 0 |
| 25 | for w ulong 8 |
| 26 | cap = sub shl ulong 1 add w 1 1 |
| 27 | for av ulong add cap 1 |
| 28 | for bv ulong add cap 1 |
| 29 | put a val av |
| 30 | put a cap cap |
| 31 | put b val bv |
| 32 | put b cap cap |
| 33 | put out val 17 |
| 34 | put out cap 19 |
| 35 | rc = qadd out a b |
| 36 | if ne qxemit rc out 0 |
| 37 | ret 2 |
| 38 | end |
| 39 | put out val 17 |
| 40 | put out cap 19 |
| 41 | rc = qsub out a b |
| 42 | if ne qxemit rc out 0 |
| 43 | ret 2 |
| 44 | end |
| 45 | put out val 17 |
| 46 | put out cap 19 |
| 47 | rc = qmul out a b |
| 48 | if ne qxemit rc out 0 |
| 49 | ret 2 |
| 50 | end |
| 51 | end |
| 52 | end |
| 53 | end |
| 54 | ret 0 |
| 55 | end |