mirror of
https://github.com/janet-lang/janet
synced 2024-11-16 13:44:48 +00:00
932a0324ee
backticks. Allow custom masks in fibers for custom error and debug handling.
22 lines
660 B
Plaintext
22 lines
660 B
Plaintext
# Example of dst bytecode assembly
|
|
|
|
# Fibonacci sequence, implemented with naive recursion.
|
|
(def fibasm (asm.asm '{
|
|
arity 1
|
|
bytecode [
|
|
(ldi 1 0x2) # $1 = 2
|
|
(lt 1 0 1) # $1 = $0 < $1
|
|
(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)
|
|
(addi 0 0 2) # $0 = $0 + $2 (integers)
|
|
:done
|
|
(ret 0) # return $0
|
|
]
|
|
}))
|