News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

C++ in ASM

Started by AeroASM, May 20, 2005, 07:43:15 AM

Previous topic - Next topic

rwalt

Quote from: AeroASM on May 20, 2005, 12:53:39 PM
I would prefer not to use any C++ compiler at all, and just write C++ compatible code in ASM, but as hutch said the overhead will probably kill me.

If your just building small applications in C++ the name decorating alone that the compiler generates is verbose. Make a C++ compiler write an ASM file for you and take a good look at it. Thats the kind of stuff you would probably have to write to accomplish what your trying to do, and it would get complicated very quickly.

Infro_X

What exactly is your end goal? Just doing a C++ progect (for a class or job), or learning C++, or doing something specific and small that'd be easier to do in C++ than ASM.
If your doing it for a class or project, obviously you gotta learn c++ (probably shouldn't of even asked this one)
If just for learning C++ than there are some tutorials i can point you to to learn.
If doing something specific in C++ and doing rest in ASM (or vise versa) then making a DLL in one of the two languages and call an exported function and have it do what you need it to in that specific language.

Which do you need?

u

Wow is it just me and Homer that understood what AeroASM wants?

There are two complete frameworks to do all the hard work for you (at no cpu-cycles cost!) : OA32 and ATC.
Get them from
OA32 - http://objasm32.tripod.com/
ATC - http://www.ultrano.com/ilix/

Writing C++ classes in them is easy . In ATC I accented on ease of use, but the documentation and available object library are not complete/big. In OA32 it's the other way around (and is more powerful too) .

But in the end, they both do the same job - enabling interfacing with C++ objects -  exactly what you said you need :) .

Here's an example of ATC vs C++ code:

class Derived : public BaseOne{
long x;
long y;
void Func1(long a);
virtual void Func2(long b);
};
...
Derived* obj1;
obj1 = new Derived;
obj1->x = 10;
obj1->Func1(7);
obj1->Func2(8);
delete obj1;


class Derived,BaseOne,C++ compatible
long x
long y
void Func1 : a
virtual Func2 : b
endclass
...
local obj1:DWORD
mov obj1,new(Derived)
;mov ecx,obj1 ; (actually can be skipped, since "new" gives the pointer in ECX too
mov [ecx].Derived.x,10
;-------[ style 1 ]--------------------\
set obj1 as Derived
pcall obj1.Func1,7
pcall obj1.Func2,8
;----------------------------------------/
;-------[ style 2 ]----------------------------\
;icall obj1,Derived,Func1,7
;icall obj1,Derived,Func2,8
;------------------------------------------------/

; (N.B: two more styles available, to select from :) )

delete obj1



Both ATC and OA32 need MASM (only its macros are powerful enough to make complex OOP possible).
Please use a smaller graphic in your signature.

Bieb

What, exactly, is this project going to be?