mirror of
https://github.com/janet-lang/janet
synced 2024-12-11 17:20:26 +00:00
6b95326d7c
remove some complexity and unexpected behavior around numbers in general as all numbers are the same number type, IEEE 754 double precision numbers. Also update examples and tests, some of which were out of date. Some more testing may be needed for new changes to numbers.
21 lines
621 B
Plaintext
21 lines
621 B
Plaintext
# Example of dst bytecode assembly
|
|
|
|
# Fibonacci sequence, implemented with naive recursion.
|
|
(def fibasm (asm '{
|
|
arity 1
|
|
bytecode [
|
|
(ltim 1 0 0x2) # $1 = $0 < 2
|
|
(jmpif 1 :done) # if ($1) goto :done
|
|
(lds 1) # $1 = self
|
|
(addim 0 0 -0x1) # $0 = $0 - 1
|
|
(push 0) # push($0), push argument for next function call
|
|
(call 2 1) # $2 = call($1)
|
|
(addim 0 0 -0x1) # $0 = $0 - 1
|
|
(push 0) # push($0)
|
|
(call 0 1) # $0 = call($1)
|
|
(add 0 0 2) # $0 = $0 + $2 (integers)
|
|
:done
|
|
(ret 0) # return $0
|
|
]
|
|
}))
|