Rust inline assembly question?

I have this snippet of code :

fn main() {
    let mut o1: i32;
    let a = 3;
    unsafe {
        asm!("
        mov rax, $0
        mul rax
        "
        : "=r"(o1) # output
        : "0"(a) # input
        : 
        : "intel")
    }
    println!("{}, ", o1)
}

Question : how to make input constrain work with "a" variable while using the intel syntax.

I'm not exactly sure what you want to do and I haven't used a lot of inline assembly, but rust uses the same inline assembly syntax as gcc, so you might be able to find what you need by searching for gcc inline assembly.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.