This is the mail archive of the
mailing list for the binutils project.
Re: How can I do calling for external address in my "C" programm by inline GAS?
> Dmitrij K <email@example.com> writes:
> > 7 asm volatile (
> > 8 "movq %0, %%rcx;" /* str into RCX is first integer argument
> > (amd64 notation) */
> > 9 "movq %1, %%rdi;" /* address of PRINTF into RDI is Must be
> > preserved by called function (amd64 notation) */
> > 10 "call * %%rdi;" /* call PRINTF */
> > 11 : /* no output */
> > 12 :"r"(str),"r"(p_printf) /* input */
> > 13 : "rcx", "rdi", "memory" /* clobbered register */
> > 14 );
> > 15 }
> On x86_64 the first parameter should go into %rdi, not %rcx. You are
> putting the function address into %rdi, so in effect you are treating
> the function address as a printf format string.
Thanks for your reply.
I did as you told me, but it is not working too :( (I had used %r15 instead
%rdi for p_printf, and %rdi for str)...
I have not ideas how I can to call func by the address.
I can't find examples of calling functions with args by address (as needs me).
I had seen examples without args only (abi, internet)...
I need help still.
Maybe you have a something tips/examples for me ?
PS: Sorry, but I have not an experience of programming on assembler (excluding
2-3 programms "hello world" for GAS 32 bit) . I have some experience of
programming on c/c++ only (And I'm away from proff, I'm an amateur, and I'm
doing it for myself).
The best Regards.