I am using eclipse Indigo with mingw GCC and AMDx64 processor
In my console "0x0" is always shown. I think this is an old example. Can anyone tell me if the syntax is incorrect or what? This should return the address of the stack pointer.
To me if I remember my at&t syntax correctly, you are moving EAX -> ESP. You should also force a specific calling convection on your function call.
I don't really see why you would want to do this, after that function returns the stack pointer is already going to be different, not to mention this will only work on 32-bit programs.
Well there might be a problem with calling convention, I'm not entirely sure what the default is for the GCC compiler, or what options you have set. I'm also unfamiliar with what calling conventions C supports.
I did run this through the mscv compiler and it appear to return the stack pointer.
Your best bet would be to look through and see exactly what's going wrong with some sort of debugger. The compiler can be doing anything really which is why I prefer to do something like this instead:
This way you don't have to worry about EAX containing a value or not, and it'll follow any calling convection / optimizations the compiler will do. Again this is Intel and MSVC syntax.