News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Details on improved OO calling mechanism

Started by johnsa, December 31, 2017, 03:30:28 AM

Previous topic - Next topic

johnsa

Hi,

I'm just about complete with the OO improvements, so I thought I'd list the types of calls that are now possible as an FYI:
(I will update the manual with more detailed examples)

Declaring two classes: Person has a reference to a Company as well.



CLASS Company
    CMETHOD Func
ENDMETHODS
    pName dq 0
ENDCLASS

; Example method that specifies a return type of REAL4.
METHOD Company, Func, <real4>, <USES rbx>, input:REAL4
    vmovss xmm0,input
    ret
ENDMETHOD

CLASS Person
CMETHOD PrintName
CMETHOD SetName
CMETHOD Calc
CMETHOD Calc2
CMETHOD DoAdd
CSTATIC IsHuman
ENDMETHODS
pName   dq 0
age        db 0
human   db 0
handle    dq 0
        lpComp  pCompany 0
ENDCLASS



Then using these 2 classes as an example, once instantiated:



person1->Calc(2.0)

person1->lpComp->Func(2.0)   ; You can de-reference pointers as many times as you want

; Use indirect registers to access objects via pointer to pointer (including evaluated SIB style addresses):
[rsi]->Calc(3.0)
[rsi]->lpComp->Func(2.0)
[rsi+rax]->Calc(3.0)
[rsi].Person->Calc(1.0)
.if( [rsi].Person->Calc(1.0) == FP4(2.0) )
[rsi+rax].Person->Calc(1.0)

; Use direct register which already holds the object pointer:
rsi->Calc(3.0)
rsi->lpComp->Func(2.0)

; Mixing object calls, normal procedures with supported parameter positions and return types.
person1->Calc( person2->Calc(1.0) )
NormalProc( person1->Calc(1.0) )       
person1->Calc( NormalProc(1.0) )   
person2->DoAdd( 1.0, NormalProc(2.0) )

; Addres-Of Operator
person1->SetName(&newName)

; VectorCall method which supports xmm, ymm and __m128 types directly via register.
person1->Calc2(xmm0,xmm1)