I've been disassembling some executable files to learn assembly language. I compiled a very simple program with GCC and Visual Studio, and noticed a strange difference in passing arguments.
(cdecl) int some_function(int, int)
VS:
mov eax, [ebp+8]
push eax
mov ecx, [ebp+4]
push ecx
call some_function
GCC:
mov eax, [ebp+8]
mov [esp+4], eax
mov eax, [ebp+4]
mov [esp], eax
call some_function
Why does GCC use mov
instead of push
?
EDIT: This is the original program for reference.
int some_function(int a, int b) {
return a + b;
}
int main(void) {
int a = 1, b = 2;
printf("string %d\n", some_function(a, b));
}