C++ and ASM 
Author Message
 C++ and ASM

How do you call C++ functions from assembly ?

What happens with the _ 's in C++ and mangled symbols ?

I am trying to declare all my data in C++ and use it from ASM.

I get a lot of linking errors.

Thanks.



Sun, 13 Jan 2002 03:00:00 GMT  
 C++ and ASM
How do you call C++ functions from assembly ?

What happens with the _ 's in C++ and mangled symbols ?

I am trying to declare all my data in C++ and use it from ASM.

I get a lot of linking errors.

Thanks.



Sun, 13 Jan 2002 03:00:00 GMT  
 C++ and ASM
On 28 Jul 1999 13:40:01 GMT, Arion Blishen

Quote:

>How do you call C++ functions from assembly ?

>What happens with the _ 's in C++ and mangled symbols ?

>I am trying to declare all my data in C++ and use it from ASM.

If you have control of the C++ source, define the functions with C
external linkage, e.g.

   extern "C" int cppfn(int p) {return p;}

Which will prevent name mangling, use a standard parameter passing
convention, and probably prepend an underscore to the function name.

If you don't have control over the C++ source, or you can't change
their linkage for some other reason (e.g., the function is overloaded
or a non-static member of a class), write some C++ wrapper functions
that have external C linkage, e.g.,

   extern "C" int c_cppfn(int p){return cppfn(p);}

And call your wrapper.

There is no standard for name-mangling or any ABI, so calling C++
functions without C external linkage directly is compiler-dependent.

Regards,

                          -=Dave
Just my (10-010) cents
I can barely speak for myself, so I certainly can't speak for B-Tree.
Change is inevitable.  Progress is not.



Sun, 13 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing arguments from C++ to ASM with Borland C++

2. C++ to asm

3. converting C++ to ASM

4. C++ to Asm

5. Please I would appreciate some input, Far pointer from C++ to asm

6. C++ And ASM

7. C/C++ to ASM

8. getting global variable from c++ in asm (MASM)

9. C++ to asm

10. Hmm C++ or Asm??

11. linking C++ and asm objects

12. C++ to Asm

 

 
Powered by phpBB® Forum Software