Hi All,
What would be involved with using existing C++ lib's with assembler?
Say you want to use a lib such as Qt or wxWidgets for a gui, you have to derive you own window object from one in their lib, how would you go about this in asm??
I'm still learning asm and I'd really like to use it for my development (particularly HLA) but I'd like to stay OS independant, I have no problem with the win32 api but I think I need a bit more functionality than what X Windows offers for linux or is it basically the same as win32??
thanks,
Mick.
Posted on 2006-09-04 17:46:33 by MickD
Using a C lib from assembly is easy.

Using C++ can get nasty because of name decoration, and -IMHO- isn't really worth it - better to use C++ with assembly, then.
Posted on 2006-09-04 19:14:37 by f0dder

Using a C lib from assembly is easy.

Using C++ can get nasty because of name decoration, and -IMHO- isn't really worth it - better to use C++ with assembly, then.



Thanks f0dder, I figured as much but it would've be nice to keep it all into one language.

If this was a bit easier in assembler I'm sure there would be a lot more people using it. :)

Posted on 2006-09-04 19:31:54 by MickD


Using a C lib from assembly is easy.

Using C++ can get nasty because of name decoration, and -IMHO- isn't really worth it - better to use C++ with assembly, then.



Thanks f0dder, I figured as much but it would've be nice to keep it all into one language.

If this was a bit easier in assembler I'm sure there would be a lot more people using it. :)


Well, it CAN be done for most stuff - use "SYSCALL" for the MASM protos, figure out what kind of name mangling your compiler uses (this *will* differ from compiler to compiler), figure out where to put "this" (register or stack), etc... it's not pretty. Macros can probably help, but still.
Posted on 2006-09-04 19:33:42 by f0dder

Well, it CAN be done for most stuff - use "SYSCALL" for the MASM protos, figure out what kind of name mangling your compiler uses (this *will* differ from compiler to compiler), figure out where to put "this" (register or stack), etc... it's not pretty. Macros can probably help, but still.


Ok, would dumpbin be suitable for figuring out the name mangling?
It seems I have a lot of study to do to fully understand what's happening here and I will do a bit more searching through threads here, though if anyone has any usefull links to any articles of what's involved that would be great.

thanks again.
Posted on 2006-09-04 19:52:19 by MickD
Doh!, I just seen the gtk/xwindows forum :shock:

I will still do some study on this as it would be nice to use 3rd party libs when needed without haveing to chop and change languages.
Posted on 2006-09-04 20:44:41 by MickD
MickD,

Have a look at this thread :

Calling C++ functions from MASM :

http://www.asmcommunity.net/board/index.php?topic=25265.0
Posted on 2006-09-05 12:32:00 by Vortex
Thanks Vortex, there's a bit there to soak up for me though :) I probably need to better understand how the inner workings of C++ classes work before the penny drops though. I have a good grip on OOP from using C#/++ for the last few years and I know that member functions are associated to vtables etc. but how they are mapped and how to inherit from or create instances of these objects and call their methods I need to get a grip on.
Cheers,
Mick.
Posted on 2006-09-05 17:44:42 by MickD
My way to learn C++'s classes handling, in order to create an OOP extention to asm, was by making different types of simple classes and looking at the compilation output (the asm/disasm). The resulting extention to asm is "ATC" at ultranos.com/asm  . ObjAsm32 seems to support arbitrary C++ classes, too.
The only problem is the decoration of class-method names - you have to manually find these decorated names from the .obj files.
Posted on 2006-09-08 15:05:39 by Ultrano
Thanks for the tip, that sounds like a good plan.
I'll start with a very simple class as you say then build on it with inheritance etc. and see what goes on.
It is a bit daunting to just open up a huge asm file and start looking for answers  :shock:

Cheers,
Mick.
Posted on 2006-09-08 22:59:44 by MickD