Calling a function in gcc inline assembly?

Generally you'll want to do something like.

Up vote 1 down vote favorite 2 share g+ share fb share tw.

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 ); c linux gcc x86 inline-assembly link|improve this question asked Nov 2 '11 at 16:53MetallicPriest3,385119 74% accept rate.

3 Do it in bare bones C first then use gcc -S to get template code which you can adapt to your needs. – Paul R Nov 2 '11 at 17:00 Paul R, nice solution, but I want a more general purpose solution. – MetallicPriest Nov 2 '11 at 17:04 2 You aren't supposed to call functions from inline assembly.

GCC doesn't try to interpret the code, so it can cause errors, such as not setting up a stack frame under the assumption that no function calls are made. – ughoavgfhw Nov 2 '11 at 17:05 1 @MetallicPriest: how is this not "general purpose"? It's the quickest/easiest way to deal with pretty much any assembly-related question - much more efficient than working everything out from scratch.

– Paul R Nov 2 '11 at 17:07 3 Why would you want to do that? Inline assembly is made on purpose such that you don't have to call an assembly function directly and such that it smoothly integrates into the surrounding code. Could you please describe more precisely what your final goal is?

– Jens Gustedt Nov 2 '11 at 17:10.

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.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions