MetallicPriest
MetallicPriest

Reputation: 30825

Calling a function in gcc inline assembly

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 );

Upvotes: 5

Views: 3502

Answers (1)

Chris Dodd
Chris Dodd

Reputation: 126448

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.

Upvotes: 9

Related Questions