Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
Created April 21, 2011 12:29
Show Gist options
  • Save rednaxelafx/934378 to your computer and use it in GitHub Desktop.
Save rednaxelafx/934378 to your computer and use it in GitHub Desktop.
Show x64 calling convention, demo'd with a call to memset(). GCC's memset is a builtin function, to disable it, use -fno-builtin. Refer to http://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI_convention
#include <string.h>
int main() {
memset(0x42, 42, 37);
return 0;
}
0000000000400498 <main>:
400498: 55 push %rbp
400499: 48 89 e5 mov %rsp,%rbp
40049c: ba 25 00 00 00 mov $0x25,%edx
4004a1: be 2a 00 00 00 mov $0x2a,%esi
4004a6: bf 42 00 00 00 mov $0x42,%edi
4004ab: e8 e8 fe ff ff callq 400398 <memset@plt>
4004b0: b8 00 00 00 00 mov $0x0,%eax
4004b5: c9 leaveq
4004b6: c3 retq
# arguments in left-to-right order:
# RDI, RSI, RDX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment