aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/add.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/add.rs')
-rw-r--r--examples/add.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/add.rs b/examples/add.rs
index 687d205..3ad8893 100644
--- a/examples/add.rs
+++ b/examples/add.rs
@@ -27,11 +27,12 @@ fn main() {
asm.call(rax);
asm.ret();
- let code = asm.into_code();
- std::fs::write("jit.asm", &code).unwrap();
-
let mut rt = Runtime::new();
- let add42 = unsafe { rt.add_code::<extern "C" fn(u32) -> u32>(code) };
+ let add42 = unsafe { rt.add_code::<extern "C" fn(u32) -> u32>(asm.into_code()) };
+
+ // Write out JIT code for visualization.
+ // Disassemble for example with `ndisasm -b 64 jit.asm`.
+ rt.dump();
let res = add42(5);
assert_eq!(res, 47);