So my C program looks like:
int main()
{
int a = 5;
int b = 1;
int c = add(a, b);
printf("%d", c);
return 0;
}
int add(int a, int b){
return a + b;
}
And I am trying to understand the behaviour of how parameters are passed into the stack. In order to do the same, I reversed the code to disassembly:
Now esp
is being copied into ebp
in the add
function, then why add 8
and 12
to access the values 5
and 1
in the next lines - shouldn't it be [ebp]
and [ebp + 4h]
? I am really confused here.
Thanks.