How to integrate an ASM obj file with a C ++ program?

I want to integrate ASM and C ++ code in Visual Studio 2010. Basically, I want to be able to use certain routines created in ASM in my C ++ code.

So I want to know:

  • How to add ASM obj files to VS2010 in the first place?
  • How do I call a function in ASM code from part of C ++ code?
  • Suppose I make a function (in ASM) that calculates a value and stores the value in a tax register. Let them say that it is called computation. Will I be able to get the return value in C ++ using something like: int val=compute(); ?
+4
source share
2 answers

All of these samples have what you need:

http://msdn.microsoft.com/en-us/library/t13a3526%28v=VS.80%29.aspx

You will need to allow the visual studio to automatically β€œconvert” them into the new project format, but I just tried it with the PRIMESSTEP2 example and worked.

All you need is a function prototype, for example:

 void sieve(void); // prototype for Sieve of Eratosthenes function 

And then you can implement them in asm and they will contact together. You return values ​​by placing them in the EAX register, and it will display as the return value in C / C ++.

+3
source

Wouldn't it be easier to use inline assembler?

0
source

All Articles