Skip to content

Instantly share code, notes, and snippets.

@wenxingxing
Created May 15, 2020 02:33
Show Gist options
  • Save wenxingxing/3876483e173b3986a15fe6f2e34bb7d2 to your computer and use it in GitHub Desktop.
Save wenxingxing/3876483e173b3986a15fe6f2e34bb7d2 to your computer and use it in GitHub Desktop.
int foo(char* x, char*, int a, int b) { return a + b; }
typedef int (*func)(int, int);
int main() {
int a = 10, b = 20, c = 0;
void* p = (void*)foo;
__asm__ __volatile__(
"movl %%edx,%%esi; "
"movl %%ecx, %%edi; "
"call *%%rax;"
: "=a"(c)
: "d"(a), "c"(b), "a"(p));
cout << c << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment