Calling a function in gcc inline assembly

不羁的心 提交于 2019-11-28 01:08:51

问题


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:


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.



来源:https://stackoverflow.com/questions/7984209/calling-a-function-in-gcc-inline-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!