Ola!!

I'm searching on the forum some news about oop in assembler but i haven't find what I need.
I need to know how to create an object in assembler without macro or similar, using only the basic instructions because I'm working on a C compiler...

can anybody hlp me?? Thanks ^_^
Posted on 2003-03-15 05:25:33 by Nikso
Basically an object is just a STRUCTURE that contains and pointers to procedures.

The whole ideea inside objects is just that: mix the data and code inside the same compact structure.

While it is not nice (and sometimes unfeasable) to copy code inside the structure itself ...pointers to such code/procedures/functions are used instead...

However i have seen some FORTH implementations that actually store the code inside the object itself for speed optimizations...but then again FORTH code is just data because of its inside simple Virtual Machine.

Add pointers to parent and a list of childs and a mechanism to copy from the parent the initial pointers to standard procedures. Also allow a mechanism for oerwriting those pointers and you have "virtual" methods. etc etc.

Study my SOL_OS code mainly the gui32.asm part ...you have there some simple GUI objects (windows, buttons, actions, events etc)...actaully ALL are the same basic window object that is just a structure with some pointers inside.

I do not use macros to init stuff :P

However IF you aim at making an full C++ compiler i guess you will have to study the asm output of some simple and pure OOP code made by one of the available c++ compilers...but i do not think there are some (if any) standards in this area... besides COM Model.
Posted on 2003-03-15 07:09:56 by BogdanOntanu
In short, the catch is this: There is not Object model for ASM period.

There is only one persons implementation to the next (ie. Borland has their views and style, as does Microsoft, as does Maelstrom, Japheth, Thomas & myself). Im sure there are other people's implementations as well, but these are authors of the variations i have seen.

You can study and create your own, or if you need to work with a specific compiler from some company, you have to learn 'their' way of doing things. As BogdanOntanu said, there is no standard, only principals. This is why you havent found what your looking for. No one here has spent their time mirroring what some compiler already does (that i know of anyways).

NaN
Posted on 2003-03-15 21:08:04 by NaN

Basically an object is just a STRUCTURE that contains and pointers to procedures.

The whole ideea inside objects is just that: mix the data and code inside the same compact structure.

Ok, then I have been right when thinking of the differences between objects and structures. (My answer was that objects contains pointers to procedures, structures doens't (unless it's a special case))
Posted on 2003-03-16 02:57:21 by scientica

To me OOP is also (and expecially) inlined code.. thus identical to a structure, in memory (but not for the compiler).

I then inline indirect calls through pointers in the structure.. and here comes polymorphism and virtual functions.

But I like to see it as structures + something to inline that makes sense only for the compiler, like a preprocessor thing.
Posted on 2003-03-16 04:04:29 by Maverick
Thank you very much for the answers!

Basically I've understand that I can implement object like I want!
For example I can built my structure like:

STRUCT myclass
MyStaticFunc dw ?
MyFunc dw ?
myval1 dw 0
myval2 dw 0
END STUCT

Both function pointers will point to functions eual for all instance but a non-static func. require a pointer to an instance of the object as a parameter... In real this thing doesn't soddisfy me at all... There is a tested and most used method???
In any cases I still have some doubit about inheritance, polymorphism and others paticularity of the oop...

Thank you again Byeeee!!!
Posted on 2003-03-16 11:32:12 by Nikso
Just rembere in the win32 FLAT model, all pointers are 32bits (DWORDS), not WORDS as your structure indicates!

:NaN:
Posted on 2003-03-16 13:23:12 by NaN
Hi,

Well that does not satisfy you because you assume that all the magic of OOP, that the HLL compilers tutorials have bombarded your mind with, has to be somehow more complex and yet somehow more easy and nice to implement. It is not and yes the pointer to the objects used is there in almost all implementations... look at some C examples of COM OOP...howevere the C++ standards CHOOSE TO HIDE this thing from you and use that as an assumed parameter that you know nothing about :) however if you choose to check the ASM code generated by C++ you will fine the pointer there...

Please understand that OOP evolved because of 2 needs:
1-Programmers refined their ideeas in time and going more and more experienced started to do such things with pointers and structures...while this was good and n\ice the HLL languages did not like it at all...so they tried to add it to their inner ways of working ...each one in his own way

2-Managers wanted a faster way to develop applications and most of all a way to delegate just parts of code to each programmer in a big team..in such a way the nobody (besides management and a few choosen/trusted programmers) knows or hold in his hand the whole project at a given time. This was anti-artistic ways of programming and indeed it has succeded.

The speed issues however failed miserably. Statistics show that because of OOP paradigm and this big team methods of interactions the speed of applications generation and the prosuctivity from programming has deteriorated constantly in the last decades...aproximatively by 100% each 5 years. We are at an all time low and we are still going down...


That is why single individuals like Linus or us or asm programmers or Ville from Menuet OS etc etc .... can design and create huge projects on their own sometimes only in ASM or plain C .... with speed that surpasses huge companys that at times own 10.000+ programmers :P


About inheritance:
---------------------------
Just copy the pointers from your parent object to your new created objects. Or either hold a link to your parent and use them right from your parent object (slower)

Polymorphism
-------------------
Use the basics of one object but hook some of its methods (like on_paint or on_mouse_down) and you will get almost the same object but with a slightly different behaviour..

Virtual
-----------------
just replace the pointers to old methods with your new methods...


Etc etc

Those nice words about OOP are just that nice words... unless you know and understand how they work and why do you really need them (sometimes like in GUI designs)

I know you are dissapointed that all theat crap is now falling apart to just some structures and pointers...

But wait a little until you understand that all progarmming languages reduce to ASM with moves from memory location to another and additions and substractions and AND and XORs :stupid:

This is the TRUTH and truth always makes you free...while nice lies always enslave you (but make you feel happy somehow) ...CHOOSE

PS
-------------
Actually OOP did evolved for a third direction also: The GUI and Menus and Screens used to add data to databases generated the Visual OOP programming stuff also
Posted on 2003-03-17 01:10:25 by BogdanOntanu

Hi Bogdan,
The speed issues however failed miserably. Statistics show that because of OOP paradigm and this big team methods of interactions the speed of applications generation and the prosuctivity from programming has deteriorated constantly in the last decades...aproximatively by 100% each 5 years. We are at an all time low and we are still going down...
We all wait for .NET for the definitive breakdown. :grin:
Posted on 2003-03-17 02:53:11 by Maverick
Yes, strucutres and objects share much in common, In many OOP implimentations, the object is just a special case structure.

Structure is importaint, since different code elements need know how to handle the object. For example, the user (client, caller, ect) needs to know the list of what functions is available, the order they are in, and that the object pointer points to a list of pointers to these functions. The object needs to know where in the object the instance data resides.

Polymorphism is just an exessivly fancy word for a way of avoiding namespace polution.

Inheritance is tricky, and comes in several varieties, from pure OOP style implimentation inheritance (re-using code) to the weaker (in the abstract sense as MS claims it leads to more robust code) COM style interface only inheritance. Either way, a cast mechanism is needed (to say get from a DOG to an ANIMAL).

Unless your goal is to build asm objects you can include in a C++ project, just dertermine what you need your objects to do, and write the framework to handle it. Its a rewarding process.
Posted on 2003-03-17 06:46:35 by Ernie
Bogdan,

I can't tell from your post. Are you down on OOP programming or just how it's implemented right now HLLs and by big companies? I agree with what you have said.
Posted on 2003-03-17 08:01:58 by drhowarddrfine
Well, I've understod a lot of think...
I didn't think that object could be so simply! (and so slow:rolleyes: )
Anyway now I'm free to built my function compiler and leave object creation in queue :grin:
Really thanks for yours help!!

ps: one day I'll understand that 'dw' doesn't meen double-word but define-word ^_^'
Posted on 2003-03-18 10:45:51 by Nikso

ps: one day I'll understand that 'dw' doesn't meen double-word but define-word ^_^'

It took me some time to under stand it to, at first I couldn't under stand why dw "ment" word untill I saw in a post that the "d" stands for "declare", then I found it easy to understand (it took a few days).
Posted on 2003-03-18 11:04:35 by scientica
Hi!

Continuing this thread... if I've 2 interfaces (i1, i2) and some classes derived from them:

class1: i1
class2: i1, i2
class3: i2

How can I know what is the position of interfaces members in the classes??? (hope u understand question).

Another thing that doesn't fit this post a lot:
What are exactly debug informations?
What type of instructions may I add and how to handle them?

thanks a lot! Bye:alright:
Posted on 2003-04-04 10:09:38 by Nikso
Nikso, you may want to check out the code available at this link:
OOPASM.ZIP
I believe this is the code from the following book:

Author Dorfman, Len.
Title Object-oriented assembly language Len Dorfman.
1st ed.
Publisher Blue Ridge Summit, PA : Windcrest, c1990.
Paging xiii, 360 p. ; 24 cm.
Posted on 2003-04-04 21:14:06 by Poimander