View Single Post
Old Aug 17th, 2006, 6:54 AM   #1
Klarre
Game engine designer
 
Klarre's Avatar
 
Join Date: May 2005
Location: Sweden
Posts: 301
Rep Power: 4 Klarre is on a distinguished road
Implement C++ functions using MASM

I have a class with a member function that I wish to implement using MASM.
class Foo
{
public:
    Foo() {}
    ~Foo() {}

    int adder(int, int); // <- This should be implemented using MASM
};

;ASM source
.486
.model flat, stdcall
option casemap :none

.code

adder proc arg1:dword, arg2:dword
	mov eax, arg1
	add eax, arg2

	ret

adder endp

end
I know how to implement C function, but now C++. I have read this http://www.codeproject.com/cpp/Using...nesVisualC.asp but with no success. How, and where, do I declare the function? Something like
extern "C" int __stdcall adder(int, int);
or similiar should be somewhere I guess...
int main()
{
    Foo foo = Foo();
    foo.adder(1, 2);
}
This does not work, cause I don't know how to declare the function. Anyone who can help me out with this?

/Thanks for your help!

/Klarre
__________________
http://www.klarre.se
Klarre is offline   Reply With Quote