mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			14 lines
		
	
	
		
			408 B
		
	
	
	
		
			Janet
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			408 B
		
	
	
	
		
			Janet
		
	
	
	
	
	
| ###
 | |
| ### 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)))
 | 
