Passing arguments from C to 64bit linux Assembly
问题 I'm trying to write my first assembly function to be called from a C program. Here is the .c part: #include <stdio.h> extern int sum(int a, int b); int main() { printf("2+3 = %d\n", sum(2,3)); return 0; } And the assembly part: .text .global sum sum: push %rbp mov %rsp, %rbp mov 8(%rbp), %rax add 12(%rbp), %rax pop %rbp ret According to some tutorials, arguments should be stored in %ebp (in 32bit version) register. However, when I compile the code above, I'm getting this result: 2+3 = 4195607