Calling a MASM proc from C++ - how to get to the cstd lib?

Started by allynm, July 17, 2009, 07:54:42 PM

Previous topic - Next topic

dedndave

it has everything you need usually
i have had occasion where i needed to use advapi32 (to use the registry functions) - so i add that to my assembly file
sometimes, you may have to bump up the .x86 number
if you use instructions like cpuid or rdtsc, i think the minimum is .586

in my template file, i use these lines, then remove the semicolons if needed

        INCLUDE \masm32\include\masm32rt.inc

;       .586
;       .686
;       .MMX
;       .XMM

;       INCLUDE \masm32\include\advapi32.inc
;       INCLUDELIB c:\masm32\lib\advapi32.lib

;       INCLUDE \masm32\macros\timers.asm

allynm

Hi everyone -

SUCCESS! I finally got the llittle asm proc that calls a c stdlib function (crt_printf) to work when called from a C caller.  Man oh man...

Here were the decisive additions.

1.  In the asm file I had to add the PUBLIC directive (PUBLIC <procname>)
2.  In the function prototype in the C caller I had to use the following expression:
     
    extern void __stdcall myproc( );  ; double underscore prefix to stdcall


So....in the future, when some green novice shows up with my question (see the thread start) you may direct them to me for assistance.  This way Michael, Hutch, Dedndave, and a number of others of you can attend to more pressing matters.

Best regards to all

Mark Allyn

jj2007

Quote from: allynm on July 22, 2009, 08:27:10 PM
SUCCESS! I finally got the llittle asm proc that calls a c stdlib function (crt_printf) to work when called from a C caller.  Man oh man...

Here were the decisive additions.

1.  In the asm file I had to add the PUBLIC directive (PUBLIC <procname>)


Congrats :U