2021-05-29

How do I pass the value of a variable in C to an argument of an instruction in inline assembly? [duplicate]

I am trying to use the value of a variable I've declared in C as the argument of a mov instruction in assembly. I've tried using a conversion character like this (where ptr is the variable):

asm("mov x9, %p\n\t" : : "r"(ptr));

But it doesn't compile and outputs an error of:

error: invalid % escape in inline assembly string
            asm("mov x9, %p\n\t" : : "r"(ptr));
                ~~~~~~~~~~~^~~~~

I've also tried it without the \n\t and it gives the same error. It's not really specific as to what's wrong with it so I'm not sure how to deal with this. How can I get it to compile or achieve the same outcome in a different way?



from Recent Questions - Stack Overflow https://ift.tt/34pA88m
https://ift.tt/eA8V8J

No comments:

Post a Comment