But...
We're still getting a warning, and this time it looks like a C++ mangling problem.
It still doesn't really see hello2, even when you call it with
Code:
asm
( // using AT&T Assembly syntax here.
"pushl szBuff;" // ;push the param onto the stack
"call _hello1;" // ;call the function
"addl $4, %esp;" // ;restore the stack to previous state
"pushl szBuff;" // ;push the param onto the stack
"call _hello2;" // ;call the function
// ;dont restore stack as hello2 will do that
);
instead of
Code:
asm
( // using AT&T Assembly syntax here.
"pushl szBuff;" // ;push the param onto the stack
"call hello1;" // ;call the function
"addl $4, %esp;" // ;restore the stack to previous state
"pushl szBuff;" // ;push the param onto the stack
"call hello2;" // ;call the function
// ;dont restore stack as hello2 will do that
);
The functions are declared as:
Code:
extern "C" void __cdecl hello1 (const char* szBuff)
//force C calling convention
{
std::cout << szBuff << std::endl;
}
and
Code:
extern "C" void __stdcall hello2 (const char* szBuff)
//force STDCALL calling convention
{
std::cout << szBuff << std::endl;
}
In case you're wondering ... using the form below
Code:
extern "C" void __stdcall hello2 (const char* szBuff)
//force STDCALL calling convention
{
std::cout << szBuff << std::endl;
}
vs. this
Code:
extern "C" void __attribute__ ((stdcall)) hello2 (const char* szBuff)
//force STDCALL calling convention
{
std::cout << szBuff << std::endl;
}
is the same thing.
The code once modified will compile on newer versions of mingw, specifically:
mingw32 gcc 2.95.3-6
mingw32 gcc 3.2
with the warning:
Warning: resolving _hello2 by linking to _hello2@4
This version would not compile at all:
mingw32 gcc 2.95.2
Any ideas? It seems to be directly related to using stdcall for hello2, because when you take that calling convention "declaration" away, it compiles cleanly.
Clifford Slocombe pointed out the need for prefixing the function names to be called in the assembly code. His post can be found at:
http://sourceforge.net/forum/forum.p...forum_id=48211
Thanks for everyone's help!
Note: Problem fixed. For full details, view the source code or the above SourceForge DevCPP Forum link for full details.
Basically, here is how it's supposed to be called:
Code:
asm
( // using AT&T Assembly syntax here.
"pushl szBuff;" // ;push the param onto the stack
"call _hello1;" // ;call the function
"addl $4, %esp;" // ;restore the stack to previous state
"pushl szBuff;" // ;push the param onto the stack
"call _hello2@4;" // ;call the function
// ;dont restore stack as hello2 will do that
);
Once again, thanks for everyone's help!