In my book I've read this:
"Data can only be added in
double word units. That is, one can not push a single byte on the stack."
So, I made a little experiment watching how arguments are passed to a function:
Consider this simple C program:
Code:
#include <stdio.h>
void func(int);
int main(void)
{
func(1);
}
void func(int a)
{
int b=2;
}
Using disassembly in .Net I was abe to see this (among other things):
Code:
func(1);
00411BFE push 1
00411C00 call @ILT+1405(_func) (411582h)
00411C05 add esp,4
So it is true! It is obvious that value of argument in this case 1 has been pushed on the stack!
Then I modified func and with the following code:
Code:
#include <stdio.h>
void func(double);
int main(void)
{
func(1);
}
void func(double a)
{
int b=2;
}
I saw this:
Code:
func(1);
00411BFE push 3FF00000h
00411C03 push 0
00411C05 call @ILT+1405(_func) (411582h)
00411C0A add esp,8
Instruction add esp,8 cleaning stack, 8 indicates 8 bytes for data type double. But what is unclear is those first two lines:
00411BFE push 3FF00000h
00411C03 push 0
How can I conclude from this that value of 1 is pushed on the stack?
I think that little endian notation is used so I try to calculate number taking 0xF03F, but that is number 61503 far away from 1.
All that assembler code was in main function, and I expected so because default calling convention that is used is --cdecl
Thanks for help!