How to call asm with function param?

when I call asm macro, I want to pass the function param into it, but I got the below error?

fn test(xx: usize) {
    // const yy: usize = xx;
    unsafe {
        asm!(
        "li a0, {arg0}",
        arg0 = xx,
        )
    }
}

error: expected one of `const`, `in`, `inlateout`, `inout`, `lateout`, `out`, or `sym`, found `xx`
  --> src/main.rs:85:16
   |
85 |         arg0 = xx,
   |                ^^ expected one of 7 possible tokens

You have to declare how will be handled the parameter with something like arg0 = in(reg) xx.

You should read the documentation about the asm macro syntax.
https://doc.rust-lang.org/beta/unstable-book/library-features/asm.html

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.