I'm using Borland C++ 5.5 for Win32.

The main code is wrtten in C.

And, I wrote some codes with MASM.

The ASM routine is following:


; Three.ASM
;-------------------------------------------------
.386
.model flat,stdcall
option casemap:none

.code

Three proc n:DWORD

mov eax,n
lea eax,
ret

Three endp

end
;-------------------------------------------------

And, The main C code is following:

/* Test.C */
/**************************************/
#include <stdio.h>

int __stdcall Three(int n);

int main(void)
{
int n;

n=4;

printf("Three(%d): %d\n",n,Three(n));

return 0;
}
/**************************************/

And, I assembled ASM source.
It was successful.

F:\TEMP>ML /c /omf Three.ASM

But, When I link, An error(following) is occured... :(

Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'Three' referenced from F:\TEMP\TEST.OBJ


Yes, The name mangling of COFF and OMF is different from each other.

CDECL is the same: ( _functionname)
But STDCALL is different from each other.
(COFF: _functionname@X ->X is the size of arguments)
(OMF: functionname)

How can I solve this problem??? :(

I have to use stdcall. no cdecl.

Thank you.
Posted on 2002-08-29 02:48:01 by nyam
nyam,

Usually you use the appropriate assembler that has the same file format as the C compiler so if you are using Borland C++, I would be inclined to use TASM to assembler modules. I think from memory that MASM has a COFF to OMF conversion as an option but I don't know if it works on Borland C++.

Regards,

hutch@movsd.com
Posted on 2002-08-29 07:55:09 by hutch--

nyam,

Usually you use the appropriate assembler that has the same file format as the C compiler so if you are using Borland C++, I would be inclined to use TASM to assembler modules. I think from memory that MASM has a COFF to OMF conversion as an option but I don't know if it works on Borland C++.

Regards,

hutch@movsd.com


Maybe he is a good guy and wants to do his job with freeware :)
Posted on 2002-08-29 07:57:55 by bazik
Thanks hutch-- for your replying. :)

I prefer to use MASM much than TASM.

And, the ASM source uses MASM specific keywords. :(

And, I love MASM. (This is a main reason... :) )

Is it Impossible? :(

Thank you!!!
Posted on 2002-08-29 09:14:56 by nyam
nyam,

Something that may be worth a try, try assembling a masm module without using the /coff option and it may build the module in OMF format. The other thing is, make sure if you are using C++ components from the compiler to do the external C declarations so that you can use an assembler module without the problem of name mangling.

I have no way of testing it but it may be worth a try so you can use MASM modules with the Borland C++ compiler.

Regards,

hutch@movsd.com
Posted on 2002-08-29 21:47:24 by hutch--
Hi,
perhaps MASM's output of omf is wrong. Try to output assembly in coff format and then change the object file format with this little utility coff2omf.exe which is included with Borland C++ 5.5.
I think it helped me once with problems delphi had accepting MASM's omf output.
Posted on 2002-08-30 13:03:26 by ramzez