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