Hello guy,

I'm a newbie in win32 and C++.
I'm just asking one question and i have found no answer. Is there a way to make a member function of a class in pure assembly with Visual C++ and Masm like we used to do with C function and Tasm.

Thanks in advance

Plotark
Posted on 2001-09-13 10:38:52 by plotark
There's no OOP support in masm itself but NaN and I are working hard on a new OOP object model for masm.. It consists of an include file with the necessary macros and a tool to create them..
Right now only the first version of the object model & tool are available (see NaN's site (nan32asm.cjb.net), also for some more info and a tutor on the first class model), which can create basic objects but doesn't have all the things C++ has like inheritance, polymorphism. Also, the tool will only create the object code to start with, all further modifications have to be done by hand.
Right now we are working on the second version of the tool, together with a new version of the include file that now supports iheritance, superclassing, polymorphism etc... The new tool will be much more powerful than the first, it allows you to create and modify classes, with an easy interface like Visual C++ has.. This tool will automatically do all the boring stuff like declaring functions, members, initial data etc, which take a lot of time to do by hand, without touching your code or other things in the file.
Unfortunately, the second tool isn't finished yet, so you can only use the first tool right now or wait for the second one.. If you're a newbie in Asm I suggest you first learn basic assembler before getting into the classes..

For more info:
NaN's site for the first tool & include, as well as an example and tutorial.
My site (look at the news page)
This thread at this board.. It's an example of the new object model (version 2), although it can not assemble, it's just a sneek peak like the title says. (btw don't get confused by the COM stuff inside, the example uses both our own object model as COM, but COM is not part of our model)

Thomas
Posted on 2001-09-13 14:34:21 by Thomas
I've readed about a OOP library for MASM here:

http://webster.cs.ucr.edu/Page_AoA/4_10.pdf

Is part of <<Art Of Assembly language>>.
Posted on 2001-09-14 02:51:34 by n u M I T_o r
n u M I T_o r: Note that this is not an 'OOP library', but a part of HLA (high level assembly).... HLA is different from masm, it requires an additional pre-assembler/compiler to assemble your source file, and has a different syntax than masm..
Posted on 2001-09-14 03:18:01 by Thomas
sorry,
but what exactly is OOP?

NOP-erator
Posted on 2001-09-14 11:14:00 by NOP-erator
Object Oriented Programming

:)


Latigo
Posted on 2001-09-14 12:09:33 by latigo
NOP-erator, OOP means "Oriented Object Programming".
<<I think>> that is a approach based on set (or class)
theory and model theory. You begin declaring a class,
like a window class. Then, you register it or alloc
space for a instance of this class (the object). This
object, alloced in memory, is a array with pointers to
functions (called the members function). You can think
in each member as a object property, a way to
react when a event has happened, like the message
handlers in the callback windows procedure. A Windows
application could be a example.

The OOP really is a high level view of programming,
it suposses code encapsulation (hide the implementation).
This is very dificult, if not imposible, in asm;
asm is meanly <<implementation>>. Another problem to
use OOP in asm is avoid that external callers access
to private members of the object. Maybe another person
can explain better than me the advantages of this
programming view. I see that is very used to create
interfaces, as Microsoft COM interfaces.

The last hutch distribution of masm includes some
tutorials about COM that can help you.

Thomas, hla did not work without MASM; only the
last versions runs with other assemblers. You say
the true, but I think that is not bad revise this
work. I'm sure that you did it and will improve it.

Of course, sorry by my english...

nmt
Posted on 2001-09-14 13:01:26 by n u M I T_o r
OOP Stands for Object Oriented Programming.
nuMIT_or discribed it well already, there's another short description in the news page at my site


The OOP really is a high level view of programming,
it suposses code encapsulation (hide the implementation).
This is very dificult, if not imposible, in asm;
asm is meanly <<implementation>>.


This is not really hard actually.. With our object model we can perfectly assemble all code into an .obj file or library, which you can use (together with the include file) in other projects.. The only thing your program needs is the include file with the class definition, and the code inside the .obj/.lib.
The class can be changed freely and you can always replace the class with a newer version without modifying the rest of a project (well not if you have deleted members of the class you used in the project of course...)


Another problem to use OOP in asm is avoid that external callers access to private members of the object.

Yes this is very hard but is it necesary? Assembly IS the most powerfull language, you can do anything you like, if it's allowed or not...
In our class model, a class consists of variables (or properties) and methods (class functions). Both can be public or private..
But these things doesn't mean a thing to masm.. There isn't even a distinction between them, just a comment that says: "these are private" and "these are public"... And of course the object tool will nicely distinct them when you are editing the definition, but in reality they are the same..
The only reason we included them is that the user can see which variables/methods it is allowed to use...So you can know what you can do safely with the object. But even here the user is free to do whatever he want, which isn't so in C++.. It's your own responsibility in asm, not the compiler's like in C++.


Maybe another person can explain better than me the advantages of this programming view. I see that is very used to create interfaces, as Microsoft COM interfaces.

I think the main advantages are reusability, independance and flexibility... Objects allow these things very easily.. Inheritance is very powerfull as well (inheritance is 'extending' an object to a 'better' object, but still allowing the original object to change, so all updates reflect in all objects that inherit that object).
COM is a different story.. I don't know really much about COM but I know it's designed to make a standard that is not language-dependant.. COM objects can be used in any programming language that supports COM, which isn't true for C++ classes (or our asm classes). COM is more complex than our object model, but of course because it's written for a different purpose.


Thomas, hla did not work without MASM; only the
last versions runs with other assemblers. You say
the true, but I think that is not bad revise this
work. I'm sure that you did it and will improve it.


Personally I don't use HLA, and our model is not designed to work together with HLA, but directly with masm. There are some basic class things in HLA but the asm classes are more powerfull..


Thomas
Posted on 2001-09-14 14:34:57 by Thomas
Hello, plotark and all!
If You are interested, You can look at my OOP approach in MASM32. My model is very poor now but it works and it's easy to use. I'm still working on it. There is no any documentation because I don't know English well. But if You will have any question or problem let me know, please, don't hesitate.
vkim
vkim@aport2000.ru
Posted on 2001-09-17 02:15:35 by vkim