flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > object-oriented programming package for FASM

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Hi everybody!
OOP in FASM have already been discussed some times in this forum, and IMHO such library or package may be a useful tool. As for me - it is. That's why I spent some time to make such pakage for my needs and decide to release it to public now. Let me say some words about it:
This OOP package is based on single inheritance mechanism with ability to implement multiply interfaces. Due to this, classes may have data fields, functions (static, virtual and abstract) and implemented interfaces and can be inherited with all of this. I have also made next things:

1. Some of COM and dynamic object creation/destruction functions are already implemented or automatically generated.
2. Run-time type identification (RTTI) mechanism.
3. Different call types (stdcall, cdecl and pascal) of classes functions support, including those of structure return type.
4. Compile-time detected OOP error messages mechanism.
5. Some optimization on classes is made automatically.
6. Some simple configuration mechanism to control work of this package.
7. Examples of COM programming and some other.
8. Some documentation, of course.

All examples are written with FASM standard includes and OOP package.
Please, tell me your opinion about this package - any improvments and suggestions are appreciated.
And a question at the end - please, tell me if all of examples work on Windows <> XP SP3?

Thanks.


Description: Package for object-oriented programming in FASM with examples and docs
Download
Filename: Classes_package_with_examples.rar
Filesize: 111.67 KB
Downloaded: 398 Time(s)


_________________
Flat Assembler is the best!
Post 04 Mar 2009, 15:02
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 03:26; edited 1 time in total
Post 04 Mar 2009, 18:29
View user's profile Send private message Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Do you mean OLE interfaces headers?
Post 04 Mar 2009, 19:16
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
I must frankly say that it is a very nice work ! I am testing it...
At the moment i would raise only an "objection" about the output, when using these nice macros:
All the samples have an only writeable/readeble .flat section.
Could you provide a simple (non COM) class-example with a "standard" .exe layout, it is to say .code/.data etc. ?
Thank You for your excellent-work!!
Regards,
hopcode
Post 20 May 2009, 21:38
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Glad you like it, hopcode!
Please tell me, if next code is what you are asking about - it is modified basic example:

Code:
format PE GUI 4.0
entry Main

CLASSES_DATA_MOVEABLE equ ; mark classes data as moveable

 ; FASM includes
 include "win32a.inc"

 ; classes package includes
 include "..\..\Classes Package\ClassesCfg.inc"
 include "..\..\Classes Package\ClassesMCode.inc"
 include "..\..\Classes Package\ClassesCore 1.8.inc"
 include "..\..\Classes Package\ClassesCode.inc"

; declare some simple class
class TIndex

 field Index  : DWORD = 0 

 ; suppose we have 2 functions to work with Index
 function Inc
 ; just for example - let it be virtual
 virtual_function Dec

endclass

; code section
section '.flat' code readable executable

; implement TIndex functions

proc TIndex.Inc this

 ; increment our object index 
 mov eax,[this]
 inc [eax + TIndex.Index]
 ret
endp ; { TIndex.Inc } 

proc TIndex.Dec this

 ; decrement our object index
 mov eax,[this]
 dec [eax + TIndex.Index]
 
 ret
endp ; { TIndex.Dec } 

; ******************   PROGRAMM ENTRY POINT   ******************
proc Main

 ; make calls of both TIndex functions
 ; this is call of static function of object  
 objfcall IndObj->Inc() ; increment index
 ; make next call via supposed "untyped" pointer to object (just for example)
 ; this is call of virtual function of object
 mov eax,IndObj
 clsfcall TIndex(eax)->Dec() ; decrement index

 ; let see index value after calls
 ; it will be zero
 mov ecx,[IndObj.Index]

; exit process
 invoke ExitProcess, NULL
endp

; data section
section '.data' data readable writeable

; classes data in this case consist of TIndex vtable
; this vtable is of only one TIndex.Dec function address
insert_classes_data ; put classes data here

; declare static instance of our TIndex
; it will contain pointer to TIndex vtable
; and value of Index = 0
IndObj  TIndex

;*********************   IMPORTS   ***********************
section '.import' import data readable writeable
;align 16
;data import

 library kernel32,           'kernel32.dll'

 include "apia\kernel32.inc"

;end data

 classes_finalize ; finalize classes

    


Any example can be done in such a way.
Regards.
Post 23 May 2009, 12:10
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
IronFelix wrote:
...if next code is what you are asking about

Yes, very flexible!!! that's exactly what i needed.
Lot of thanx.
I think that your macros will trace a new path in OOP (simple and COM) with Fasm.

Regards,
hopcode
Post 24 May 2009, 07:48
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
You are welcome, hopcode!
Lot of thanks to Tomasz Crysztar for his amazing FASM!
Regards.
Post 24 May 2009, 08:05
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Grysztar Smile
Post 24 May 2009, 08:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Ooops Embarassed Sorry, Tomasz ! Smile
Post 24 May 2009, 09:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.