Last active
August 5, 2020 11:36
-
-
Save vext01/da1468a84936d8c93caeef18595be416 to your computer and use it in GitHub Desktop.
dynasm fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use dynasmrt::{dynasm, DynasmApi, x64::Rq::RAX, Register}; | |
macro_rules! reg_to_mem { | |
($ops: expr, $reg: expr, $mem: expr) => { | |
dbg!($ops); | |
dynasm!($ops | |
; mov QWORD $mem, $reg | |
); | |
} | |
} | |
fn main() { | |
let mut ops = dynasmrt::x64::Assembler::new().unwrap(); | |
dynasm!(ops | |
; mov QWORD [rbp + 8], rax | |
); | |
reg_to_mem!(ops, RAX.code(), [rbp + 8]); | |
let buf = ops.finalize().unwrap(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Checking dynasm-mem v0.1.0 (/home/edd/research/dynasm-mem) | |
error[E0425]: cannot find value `ops` in this scope | |
--> src/main.rs:6:17 | |
| | |
6 | dynasm!($ops | |
| ^^^^ not found in this scope | |
... | |
20 | reg_to_mem!(ops, RAX.code(), [rbp + 8]); | |
| ---------------------------------------- in this macro invocation | |
| | |
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | |
error: aborting due to previous error | |
For more information about this error, try `rustc --explain E0425`. | |
error: could not compile `dynasm-mem`. | |
To learn more, run the command again with --verbose. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment