I can do this:
#[test]
fn test_00() {
let mut ops = dynasmrt::x64::Assembler::new().unwrap();
let instrs = ops.offset();
let mut x: i64 = 23;
dynasm!(ops
; .arch x64
; mov rax, QWORD (&mut x as *mut i64 as u64 as i64)
; mov rax, [rax]
; ret
);
x = 24;
let buf = ops.finalize().unwrap();
let hello_fn: extern "sysv64" fn() -> u64 = unsafe { mem::transmute(buf.ptr(instrs)) };
assert_eq!(hello_fn(), 24);}
but I am having problem trying to convert it to a single instruction. In particular, the inside of '[x]
seems to want a i32 instead of an i64.