spinix-hive/devel/fibo.spn

32 lines
632 B
Plaintext
Raw Normal View History

con
_clkmode = $62
_clkfreq = $4E495053 ' SPIN
obj
c : "clibsd"
pub main(argc, argv) | n, startTime, endTime, executionTime, rawTime
c.enter(argc, argv)
c.printf0(string("hello, world!\n"))
n := 0
repeat while n =< 26
c.printf1(string("fibo(%d) = "), n)
startTime := clock
result := fibo(n)
endTime := clock
rawTime := endTime - startTime
executionTime := rawTime / (CLKFREQ / 1000)
c.printf3(string("%d (%dms) (%d ticks)\n"), result, executionTime, rawTime)
n++
c.exit(0)
pub clock
result := cnt
pub fibo(n)
if n < 2
return n
else
return fibo(n - 1) + fibo(n - 2)