JanetDocsPlaygroundI'm feeling luckyGitHub sign in

asm



    cfunction

    (asm assembly)

    Returns a new function that is the compiled result of the assembly. 
    The syntax for the assembly can be found on the Janet website, and 
    should correspond to the return value of disasm. Will throw an 
    error on invalid assembly.


1 exampleSign in to add an example
Loading...
# see https://janet-lang.org/docs/abstract_machine.html

(def plus10
 (asm 
   '{
     :arity 1
     :bytecode @[(ldi 1 10)    # $1 = 10
                 (add 2 0 1)   # $2 = $0 + $1
                 (ret 2)]}))   # return $2

(plus10 1) # -> 11
felixrPlayground