Because your OS is 64-bit, so addresses are too.
Parameters are passed with push
instruction. This instruction pushes operand into stack and decreases esp
based on stack frame size. In 64-bit OS, esp
is decreased by 8 for next address. In 32-bit OS, you will see 4 byte difference only.
If it was not function argument, you would not have seen this behavior. For example, in the following code you should see 4 byte difference in addresses:
void foo()
{
int a = 0;
int b = 0;
printf("%u\n", sizeof(int));
printf("%u\n", &a);
printf("%u\n", &b);
}
EDIT:
When you pass parameters, they are allocated on stack, so this following example:
struct _asd
{
int a;
int b;
char c[6];
};
void foo2(struct _asd a, int b)
{
printf("%u\n", sizeof(struct _asd));
printf("%u\n", &a);
printf("%u\n", &b);
}
In this case, sizeof(struct _asd)==16
, so you see a result like this:
16
3754948864
3754948880
and as you see difference is 16. Just remember that you need to test this when you build Release mode, in Debug mode you see something like this:
16
3754948864
3754948884
a 20 byte difference, Because in Debug mode, compiler allocates more memory for structures. Now if you write your code like this:
struct _asd
{
int a;
int b;
char c[6];
};
void foo2(struct _asd *a, int b)
{
printf("%u\n", sizeof(struct _asd));
printf("%u\n", a);
printf("%u\n", &b);
}
Result will be like this:
16
827849528
827849520
Only 8 bytes difference, because now only addresses is sent to function which is only 8 bytes long.
As a side note, in 64-bit OS, arguments are mostly passed by registers. For example first 4 parameters are normally passed by registers when you compile your code in MSVC. But in current topic, parameters are accessed by address and this will be meaningless for registers. So I think compiler automatically passed such parameters by pushing them into stack.