Hey all, I have been making great progress lately and figuring out some neat stuff. My latest accomplishment is devising a methology of writing CLASSED OBJECTS in ASM. Im pretty sure Ernie knows all about this, since the discovery stemmed from his COM methology. But if others are interested, Im thinking of making it my first tutorial??? Perhaps with some DirectX COM's etc. What do you think?? Good/Bad idea?? My current working example is a Raster Object (like C++) that rotates on the screen. It has methods (draw itself In DirectDraw), as well as stucture data about itself (like where it is on the screen). If there is good feedback i will go at it... NaN
Posted on 2001-05-05 20:50:00 by NaN
Lemmy see! Lemmy see! Lemmy see! Please? :-) Seriously, I'd be interested in any methodology in defining classes in asm. I'm actually dissapointed in the current CoLib stuff in how a class is defined, it's too hit-and-miss, too dependent on the programmer knowing all, too little compiler checks.
Posted on 2001-05-06 00:11:00 by Ernie
No presure, no presure... :P I dont know of any existing standards, but this is bases off of my C++ experiences. I can post the source i have ready now for scrutinizing, but it comes with little explainations as of yet :) I have it in two parts so far, Objects.inc, which is the controlling macro file, and any class you decide to write, but the class has to adhear to some standards, not too far from the present COM stuf. Here is the Object.inc

; --=====================================================================================--
; OBJECTS.INC
; --=====================================================================================--
; By NaN (Jaymeson Trudgen == jaymeson@hotmail.com )
; May 6, 2001
;
; This is the include needed to implement classes in WIN32ASM, as i have designed.
; Three main macros here: 
;         
;         METHOD         ~ Calls a method in a class
;         NEWOBJECT      ~ Creates a new 'instance' object
;         DESTROY        ~ Destroys existing object (MUST BE DONE!)
;
; --=====================================================================================--
METHOD MACRO pInterface:REQ, Interface:REQ, Function:REQ, args:VARARG
    LOCAL istatement, arg
    FOR arg,      ;; run thru args to see if edx is lurking in there
        IFIDNI <&arg>, 
            .ERR 
        ENDIF
    ENDM
    IFIDNI <&pInterface>, 
        .ERR 
    ENDIF
    istatement CATSTR ,<&Function, pInterface>
    IFNB      ;; add the list of parameter arguments if any
        istatement CATSTR istatement, <, >, <&args> 
    ENDIF 
    mov edx, pInterface
    istatement
ENDM
; --=====================================================================================--
ALLOCATE_FROM_HEAP MACRO ObjName:REQ
        invoke GetProcessHeap
        invoke HeapAlloc, eax, NULL, SIZEOF ObjName
ENDM
; --=====================================================================================--
FREE_FROM_HEAP MACRO pMem:REQ
        invoke GetProcessHeap
        invoke HeapFree, eax, NULL, pMem
ENDM        
; --=====================================================================================--
NEWOBJECT MACRO pName:REQ, ObjType:REQ, args:VARARG

     LOCAL instring
     instring CATSTR ,<&ObjType>,<_Init, eax,>,<&args>
     
     ifndef &pName
     .data?
     &pName&Data typedef ptr ObjType
     pName &pName&Data ?
     .code
     endif
     
     ALLOCATE_FROM_HEAP ObjType
     mov pName, eax
     instring
ENDM
; --=====================================================================================--
DESTROY MACRO pName, ObjType
     LOCAL instring
     instring CATSTR ,<&ObjType>,<_Destroy, pName>
    
     instring
     FREE_FROM_HEAP pName
ENDM     
; --=====================================================================================--     
Next is my RASTER CLASS

; --=====================================================================================--
; RASTER CLASS
; --=====================================================================================--
; By NaN (Jaymeson Trudgen == jaymeson@hotmail.com )
; May 6, 2001
;
; This is my first CLASS written in WIN32ASM.  It is designed to work with the OBJECTS.INC
; 
; --=====================================================================================--
; CLASS METHOD PROTOS
; --=====================================================================================--
     RASTERS_Init             PROTO     :DWORD, :DWORD
     RASTERS_Destroy          PROTO     :DWORD
     
; --=====================================================================================--
; FUNCTION POINTER PROTOS
; --=====================================================================================--
     RotateProto    typedef   PROTO     :dword
     DrawProto      typedef   PROTO     :dword, :dwor
Posted on 2001-05-06 02:46:00 by NaN
For me, all tutorials are welcome :)
Posted on 2001-05-06 17:54:00 by wolfao
lets see it NaN! smurf
Posted on 2001-05-06 19:31:00 by smurf