News:

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

Main Menu

HJWasm 2.25 Object Orientation Guide

Started by johnsa, April 06, 2017, 06:08:42 AM

Previous topic - Next topic

jj2007

Interesting, although too C++ for my taste  ;)

METHOD Person, Init, age:BYTE
LOCAL isAlive:DWORD
; Internally the METHOD forms a traditional procedure, so anything that you can
; do in a PROC you can do in a method.
; On entry into any method RCX is a pointer to the instance
; and the correct reference type is assumed.
mov [rcx].human, 1 ; Hence this is possible.
mov (Person PTR [rcx]).human, 1 ; Alternative forms of reference.
mov [rcx].Person.human, 1 ; " "
mov isAlive,0
mov al,age
mov [rcx].age,al
.if( age < 100 )
  mov isAlive,1
.endif
; Constructor MUST return thisPtr in rax (the implicit self reference
; passed in RCX).
mov rax,thisPtr
ret
ENDMETHOD


Are this just examples how to do it, or does the library provide some of them? Could you use more assembly-style code like this?
and isAlive,0
mov al,age
mov [rcx].age,al
.if age < 100
   inc isAlive
.endif

johnsa

Hey,

That was just an example.

Inside a method you can code it however you like :) It's really just a PROC behind the scenes with this sort of structure :

MyClass_MyMethod PROC FRAME thisPtr:QWORD, <args>
asssume rcx:PTR MyClass
.
.

So you can do whatever you want :) follow the rules, break the rules.. make up new rules lol

mabdelouahab

How I can use it?
... Error A2260: Missing .ENDPROLOG: _Person_Release  ENDCLASS(11)[....

johnsa

There was a small bug in the $DELETE implementation which I've fixed. The new packages are up on the site and Git, dated 7th April.
The packages now include a new sample oo1.asm which demonstrates a few of the new features and using the OO layer.

mabdelouahab