This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

interfacing C++ and assembly?



I know how to write functions in assembly so that they C-callable; if the C-callable name is foo() then the assembly function is named _foo().

What if I want to use C++ and optimize a class method in assembly? How do I do that? I assume the only major issues are:

 - naming

 - accessing the "this" pointer

 - accessing class members by somehow knowing offsets

 

and if I don't want to worry about the last two, then perhaps I would write a static member function and do this:

class MyClass

{

  int x;

  static int _doSomething(int u); // implement this in assembly

public:

  inline void doSomething() { x = _doSomething(x); } // lightweight C++ wrapper to handle the class member / "this" pointer stuff

};