The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: czx_204 on May 16, 2012, 10:45:59 AM

Title: Links an assembly file with a C/C++ file
Post by: czx_204 on May 16, 2012, 10:45:59 AM
Here is the code in C++:


   #include <iostream>
   using namespace std;
   double CombineC(int a, int b, int c, int d, int e, double f)
   {
         return (a+b+c+d+e)/(f+1.5);
   }

   // NOTE: extern "C" needed to prevent C++ name mangling
   extern "C" double CombineA(int a, int b, int c, int d, int e, double f);

   int main(void)
   {
         cout << "CombineC: " << CombineC(1,2,3,4, 5, 6.1) << endl;
         cout << "CombineA: " << CombineA(1,2,3,4, 5, 6.1) << endl;
         return 0;
   }

   
I want the CombineA function to do the same thing as CombineC does and to be written in .asm. The program is in 32-bit.

We are using MASM32 ver11 and Visual Studio 2010. Could anyone simply write the assembly part for this and tell me what I should do to link them?

Sorry I don't have any experience about either assembly or C but have to do this... Any help will be appreciated!
Title: Re: Links an assembly file with a C/C++ file
Post by: ragdog on May 16, 2012, 11:29:42 AM
Why make you not a Static Libaray
Title: Re: Links an assembly file with a C/C++ file
Post by: hutch-- on May 16, 2012, 01:20:39 PM
> Sorry I don't have any experience about either assembly or C but have to do this... Any help will be appreciated!

If you neither write C or assembler, the solution is "Rent A Coder". This forum is not a grovelware emporium.