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 / research / om-bench / controls / lib.om
| 1 | note Read unsigned decimal numbers separated by spaces or newlines from stdin; print their sum. |
| 2 | global inb uchar 65536 |
| 3 | global outb uchar 32 |
| 4 | fn readall to ulong |
| 5 | n = ulong 0 |
| 6 | while lt n 65536 bound 65537 |
| 7 | k = read 0 inb n sub 65536 n |
| 8 | if lt k 0 |
| 9 | exit 2 |
| 10 | end |
| 11 | if eq k 0 |
| 12 | break |
| 13 | end |
| 14 | n = add n ulong k |
| 15 | end |
| 16 | ret n |
| 17 | end |
| 18 | fn printu v ulong to void |
| 19 | i = ulong 31 |
| 20 | put outb i 10 |
| 21 | x = v |
| 22 | while true bound 21 |
| 23 | i = sub i 1 |
| 24 | put outb i uchar add rem x 10 48 |
| 25 | x = div x 10 |
| 26 | if eq x 0 |
| 27 | break |
| 28 | end |
| 29 | end |
| 30 | off = i |
| 31 | k = write 1 outb off sub 32 off |
| 32 | if ne k long sub 32 off |
| 33 | exit 3 |
| 34 | end |
| 35 | end |