1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-25 16:00:27 +00:00
janet/examples/jitfn/jitfn.janet
2022-12-04 11:08:17 -06:00

14 lines
408 B
Plaintext

###
### Relies on NASM being installed to assemble code.
### Only works on x86-64 Linux.
###
### Before running, compile hello.nasm to hello.bin with
### $ nasm hello.nasm -o hello.bin
(def bin (slurp "hello.bin"))
(def f (ffi/jitfn bin))
(def signature (ffi/signature :default :void))
(ffi/call f signature)
(print "called a jitted function with FFI!")
(print "machine code: " (describe (string/slice f)))