在gcc内联汇编中调用函数

时间:2011-11-02 16:53:13

标签: c linux gcc x86 inline-assembly

说,我想在gcc的内联汇编中调用具有以下签名的函数。我怎么能这样做?

int some_function( void * arg );

1 个答案:

答案 0 :(得分:8)

一般来说,你会想做类似

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

也就是说,您根本不想在内联asm中执行函数调用。这样您就不必担心调用约定或堆栈帧管理的细节。