News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

call C++ func from asm

Started by qwe522y, November 03, 2011, 07:37:05 AM

Previous topic - Next topic

jj2007

Luce,

My version works perfectly, see attachment. There is no need for PROTO C if you use stdcall in the C code, too.

By the way, Olly has massive problems with the executable.

ToutEnMasm

Quote
My version works perfectly, see attachment. There is no need for PROTO C if you use stdcall in the C code, too.
The need is to use the same type of prototype ,c or stdcall or ....

qWord

Quote from: ToutEnMasm on November 04, 2011, 06:01:45 PMThe need is to use the same type of prototype ,c or stdcall or ....
What is wrong with jj's first example?

Quote from: qwe522y on November 03, 2011, 07:37:05 AM.model flat, stdcall
asmprint proto
...
Quote from: jj2007 on November 03, 2011, 08:31:39 AMextern void __stdcall asmprint();
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: qWord on November 04, 2011, 06:49:33 PM
What is wrong with jj's first example?

Actually, nothing is wrong :bg
But...
Quote from: jj2007 on November 04, 2011, 08:27:54 AM
Here is what works for me:

"%ProgramFiles%\Microsoft Visual Studio 9.0\VC\bin\cl.exe" /c /Zl /Fa /Fp TestAsmC.c
\Masm32\bin\ml.exe /nologo /c /coff  /Fl /Sn /Fo "TestC"
\masm32\bin\link.exe \masm32\lib\msvcrt.lib TestAsmC.obj "TestC.obj" /OUT:"TestC.exe"
... don't let the C compiler take its own crt library. You also need environment variables for the C compiler part (and for reasons I don't understand, my puter refuses to accept the global include variable ::), so I need to set it in the batch file)

Overall, mixing asm and C (or C++, even Visual Basic for apps) works just fine, and the size of the final exe is quite convincing at 1024 bytes, but it is not for noobs - finding the right setup is kind of messy.

ToutEnMasm

What is wrong is,i rewrite it in bold.
Quote
My version works perfectly, see attachment. There is no need for PROTO C if you use stdcall in the C code, too
With the answer:
The need is to use the same type of prototype ,c or stdcall or ....
Did you see know what is the subject ?..

jj2007

Quote from: ToutEnMasm on November 05, 2011, 05:37:35 AM
With the answer:
The need is to use the same type of prototype ,c or stdcall or ....

Which is exactly what I did, so I sincerely hope that you are finally happy, Luce :bg

ToutEnMasm


Good,
There is sometimes need to be more clear.Sorry, if it was writed too big.  :P