On Oct 5, 2:01 am, bluejo...@gmail.com wrote:
> Is it possible to make a class with some of its member functions
> written in assembly (in a separate file)? For example:
> class C {
> public:
> int method (void);
> }
> ====ASM file====
>
> .global method
>
> method:
> XOR EAX,EAX
> RET
>
> =========
It's possible, but it's a lot of work. You have to specify the
mangled name in the assembler, and perhaps deal with special
ways the this argument may be passed. In general, if I had to
do this, I'd define a C-style struct, and extern "C" functions
which manipulated it, and then wrap that in a class for C++.
The C API is generally well defined and stable, while the same
isn't necessarily true for C++.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34