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 / ng / front / runs / fib30.om
| 1 | note fib30: kernels/fib38.om with fib(30) (was 38), for ngrun in gate-front-ir. fib: doubly recursive |
| 2 | note Fibonacci (ulong); prints fib(n). Call and return heavy. |
| 3 | note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without |
| 4 | note start-up and output) as one decimal line on stderr; stdout is unchanged. |
| 5 | global out uchar 32 |
| 6 | fn putnum fd int v ulong to void |
| 7 | put out 31 10 |
| 8 | p = ulong 31 |
| 9 | x = v |
| 10 | while gt x 9 |
| 11 | p = sub p 1 |
| 12 | put out p uchar add rem x 10 48 |
| 13 | x = div x 10 |
| 14 | end |
| 15 | p = sub p 1 |
| 16 | put out p uchar add x 48 |
| 17 | w = write fd out p sub 32 p |
| 18 | end |
| 19 | fn fib n ulong to ulong |
| 20 | if lt n 2 |
| 21 | ret n |
| 22 | end |
| 23 | a = fib sub n 1 |
| 24 | b = fib sub n 2 |
| 25 | ret add a b |
| 26 | end |
| 27 | fn main to int |
| 28 | t0 = monons |
| 29 | r = fib 30 |
| 30 | t1 = monons |
| 31 | putnum 2 ulong sub t1 t0 |
| 32 | putnum 1 r |
| 33 | ret 0 |
| 34 | end |