On Friday 13 August 2010 11:08:05 you wrote: > On 08/12/2010 05:44 PM, Job Noorman wrote: > > Hi, > > > > I am trying to make a direct function call from inline assembly like this: > > asm("call %0" : : "i"(func)); > > > > This doesn't work because GCC will generate something like > > > > call $mangledFunc > > > > which will give an assembly error. > > Is there a way to do this? > > > > Thanks in advance! > > Job > > > > PS: I know I can do something like > > > > asm("call *%0" : : "r"(func)); > > > > But then it's not a direct call anymore. > > > > PPS: I also posted this question on StackOverflow: > > http://stackoverflow.com/questions/3467180/direct-call-using-gccs-inline- > > assembly > > I don't know why you get an assembly error. It would help a great > deal if you provided an actual compilable example that displays the > problem, preferably for x86. It's impossible to answer your question > because there is not enough information. > > Andrew. Ok here it goes: //file main.cpp void func() {} int main() { //this works but GCC generates an indirect call: // movl $_Z4funcv, %eax // call *%eax asm("call *%0" : : "r"(func)); //this is what I conceptually want to do but doesn't work because //GCC generates // call $_Z4funcv //which gives an error from the assembler: // main.cpp: Assembler messages: // main.cpp:20: Error: suffix or operands invalid for `call' //I would like to find a way to make GCC generate the following: // call _Z4funcv //(note there is no "$") asm("call %0" : : "i"(func)); }