Calling a function in gcc inline assembly

前端 未结 1 1611
孤城傲影
孤城傲影 2020-12-18 08:02

Say, I want to call a function with the following signature in inline assembly of gcc. How can I do that?

int some_function( void * arg );
相关标签:
1条回答
  • 2020-12-18 08:53

    Generally you'll want to do something like

    void *x;
    asm(".. code that writes to register %0" : "=r"(x) : ...
    int r = some_function(x);
    asm(".. code that uses the result..." : ... : "r"(r), ...
    

    That is, you don't want to do the function call in the inline asm at all. That way you don't have to worry about details of the calling conventions, or stack frame management.

    0 讨论(0)
提交回复
热议问题