Click to See Complete Forum and Search --> : How to call a "C"-function present in a different file from assembly language code


tanniru
June 28th, 2006, 10:38 AM
How to call a "C" function present in some file from assembly language code ( x8086).

We are using MASM611 compiler i.e., ML.EXE to compile the Assembly language code.


Assembly language file ( .asm ) wants to call a C function present in a C language file ( .C ) file. .C file contains only functions...


Please reply me immediately ..... THANKS IN ADVANCE

Krishnaa
June 28th, 2006, 10:50 AM
You need to compile the C file saperatly and get the OBJ file, include this in your assembly project. And use the function like it is in assembly. You can use VC++6 to compile that C file.

svenhag
June 28th, 2006, 04:48 PM
You will probably also need to export the symbol in the asm file in some way. I'm not 100% sure about MASM but I think you use the PUBLIC keyword for that. So for example to make the symbol func available to your C code you write 'PUBLIC func'.

svenhag
June 28th, 2006, 04:58 PM
Oh sorry you wanted the other way. Well then I think you have to declare the C function as extern in your asm file. (At least you have to do that with nasm)