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 {
        "li a0, {arg0}",
        arg0 = xx,

error: expected one of `const`, `in`, `inlateout`, `inout`, `lateout`, `out`, or `sym`, found `xx`
  --> src/
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.

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.