title: how call a function with parameters in eax and esi. gcc c++
body: <p>I need to call a function pointer using gcc that i can´t typedef in c++. I´m not good at asm so i would appreciate your help.</p>
  
  <p>The function passes arg1 in eax and arg2 in esi. args are pushed right to left and the caller cleans the stack</p>
  
  <pre><code>signed int __usercall o_Fkt&lt;eax&gt;(int a1&lt;eax&gt;, int a2&lt;esi&gt;, int a3, int a4, int a5)
  </code></pre>
  
  <p>edit:
  Thanks Willem. I had success calling it this way:</p>
  
  <pre><code>    int callfn(void* a1, void* a2, int a3, int a4, void* a5 )
      {
          int result;
          unsigned long fktAddr = 0x0092FE40;
          __asm volatile(
                  "push %[a5]\n\t"
                  "push %[a4]\n\t"
                  "push %[a3]\n\t"
                  "call edx\n\t"
                  "add esp, 12"
                  : "=a" (result)
                  :  "d" (fktAddr), "a" (a1), "S" (a2) , [a5] "r" (a5), [a4] "r" (a4), [a3] "r" (a3)
                  : "memory"
          );
          return result;
      }
  </code></pre>
  
  <p>edit2: added "memory" to clobber list</p>