I\'m trying to find out why in windows has so much more instructions for the same program than linux.
So I just used int a=0xbeef;
and printf(\"test\\n\");
You seem to be compiling with old 3.x series gcc
, you'd better upgrade. Newer versions don't invoke alloca
. I suspect the particular version of alloca
might use register convention so the mov 0x10,%eax
is probably setting up the argument for that call.
__main
is a startup function defined in crtbegin.o
that executes global constructors and registers a function using atexit
that will run the global destructors.
Also note that main
gets special treatment, like the stack alignment code and the above-mentioned initialization. It may be a good idea to instead compare a "plain" function if you are just interested in code generation issues.
One notes that in the upper example the compiler is calling puts, while in the lower it is printf. I would suspect you have optimization on in the top example, but not on the lower example.
It also might be a debug vs non-debug build.