flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > FASM vs TASM

Author
Thread Post new topic Reply to topic
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 16 Jun 2005, 11:57
1. Suppose, I have following structure defininion in TASM:
struc CMyApp
m_hInst dd ?
m_gcRefs dd ?
ends

I can use following instruction in TASM to address structure field:
mov [(CMyApp ptr ebx).m_hInst],eax

How can I do it in FASM?


2. To implement structure inheritance in TASM I can do th following:
struc CMyStruct1
m_field1 dd ?
m_fiend2 dd ?
ends

struc CMyStruct2 CMyStruct1
m_field2 dd ?
ends

How can I do it in FASM?
Post 16 Jun 2005, 11:57
View user's profile Send private message ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 16 Jun 2005, 12:08
1. most native way
Code:
;declare structure
struc CMyApp{
.m_hInst dd ?
.m_gcRefs dd ? }
;declare relative offsets (CMyApp.m_hInst=0,CMyApp.m_gcRefs=4)
virtual at 0
CMyApp CMyApp
end virtual
;use
mov [ebx + CMyApp.m_hInst],eax
    

or if you always keep CMyApp pointed by ebx you can even do
Code:
struc CMyApp{
.m_hInst dd ?
.m_gcRefs dd ? }
virtual at ebx ;<--- note this
CMyApp CMyApp
end virtual
...
mov [CMyApp.m_hInst],eax
    

but i don't recommend this, it unclear if someone reads your code without knowing CMyApp.m_hInst is "at ebx".

note there are new struct macros which declare relative offsets instead you (no need for "virtual at" part) and allow you unions, nested structures etc.

2. I don't know what this code does in TASM, sorry
Post 16 Jun 2005, 12:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 16 Jun 2005, 12:18
In question 2 I made a mistake, excuse me.

Code in TASM

struc CMyStruct1
m_field1 dd ?
m_field2 dd ?
ends

struc CMyStruct2 CMyStruct1 ; like class CMyStruct2: public CMyStruct1; in C++
m_field3 dd ?
ends

Generates following structure

struc CMyStruct2
; fields from CMyStruct1
m_field1 dd ?
m_field2 dd ?
; new field
m_field3 dd ?
ends

Have a FASM such inheritance support?
Post 16 Jun 2005, 12:18
View user's profile Send private message ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 16 Jun 2005, 12:30
2. Maybe it could work like this (i am not sure, this is quite new feature)
Code:
struc CMyStruct2
{
   . CMyStruct1
   .m_field3 dd ?
}    

"." inside struc refers to name of instance when structure is used. So this way, when you declare instance of CMyStruc2, then instance of CMyStruct1 with sae name gets declared as a part of it. But i am really not sure about this.
Post 16 Jun 2005, 12:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 16 Jun 2005, 12:55
Yes vid, this is exactly the correct solution.

It should be also easy to extend the new "struct" macro with emulation of this TASM's feature, using the above trick.
Post 16 Jun 2005, 12:55
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 17 Jun 2005, 04:03
Quote:

Code:

struc CMyStruct2
{
. CMyStruct1
.m_field3 dd ?
}

What does this do, and is it covered in the manual? You know Privalov, it would be nice if you could have a manual that comes with only the latest features that have been added.
I know "WHATSNEW.TXT" is supposed to tell this stuff but it doesn't always.
Post 17 Jun 2005, 04:03
View user's profile Send private message AIM Address Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 17 Jun 2005, 08:59
i think that after 1.64 is out, there will b new documentation covering it all globally. I see 1.64 as drastic advance in FASM evolution.
Post 17 Jun 2005, 08:59
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 17 Jun 2005, 09:54
vid wrote:
1. most native way
Code:
;declare structure
struc CMyApp{
.m_hInst dd ?
.m_gcRefs dd ? }
;declare relative offsets (CMyApp.m_hInst=0,CMyApp.m_gcRefs=4)
virtual at 0
CMyApp CMyApp
end virtual
;use
mov [ebx + CMyApp.m_hInst],eax
    

or if you always keep CMyApp pointed by ebx you can even do
Code:
struc CMyApp{
.m_hInst dd ?
.m_gcRefs dd ? }
virtual at ebx ;<--- note this
CMyApp CMyApp
end virtual
...
mov [CMyApp.m_hInst],eax
    

but i don't recommend this, it unclear if someone reads your code without knowing CMyApp.m_hInst is "at ebx".

note there are new struct macros which declare relative offsets instead you (no need for "virtual at" part) and allow you unions, nested structures etc.



Ok. And what is if I want to reassign CMyApp to another register? If I try to compile such code:

virtual at ebx ;<--- note this
app CMyApp
end virtual

......
some other processing
......

virtual at ecx
app CMyApp ;<--- app assinged to another register
end virtual


I receive a message "Symbol already defined".

Which symbol already defined?
How can I purge its definition before reassigning the "app"?
Post 17 Jun 2005, 09:54
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 17 Jun 2005, 10:23
The manual is already updated to cover all the new features. I don't plan doing any huge changes in it for the 1.64 - just a few more sections might be added, but the existing features are generally already documented there.
Post 17 Jun 2005, 10:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 17 Jun 2005, 10:29
afw2004: you cannot define the same label twice, and you tried to redefine the labels in your sample. What I usually recommended was something like:
Code:
virtual at ebx
 app_ebx CMyApp
end virtual

virtual at ecx
 app_ecx CMyApp
end virtual    

defining the labels for different addressings in a way, which also clearly suggests which is which.

Or you can go with the "struct" macro (or even simple "virtual at 0" approach), and access it this way:
Code:
mov [ebx+CMyApp.m_hInst],0    
Post 17 Jun 2005, 10:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 17 Jun 2005, 10:34
THEWizardGenius: for the detailed information about only recently added features read this thread (and follow the links within it aswell): http://board.flatassembler.net/topic.php?t=3592
Post 17 Jun 2005, 10:34
View user's profile Send private message Visit poster's website Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 18 Jun 2005, 09:39
To define data of TBBUTTON type (for example) in data section I can write following code in TASM:

LABEL tbb
TBBUTTON <STD_FILENEW,ID_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,-1>
TBBUTTON <STD_FILEOPEN,ID_FILE_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,-1>
TBBUTTON <STD_FILESAVE,ID_FILE_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,-1>

How can I define such structured data in data section in FASM (is it possible to do without having to add parameters in structure definition)?
Post 18 Jun 2005, 09:39
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 18 Jun 2005, 10:46
Again the new "struct" macro will take care of it for you automatically - when using bare "struc" feature you have to define parameters yourself (but this on this other hand allows you to choose any parameters with any syntax you prefer for such constructions).
Post 18 Jun 2005, 10:46
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 18 Jun 2005, 14:19
I have also updated the new "struct" macro to allow syntax like:
Code:
struct CMyStruct2 CMyStruct1
 m_field2 dd ?
ends     

I invite you to try it.
Post 18 Jun 2005, 14:19
View user's profile Send private message Visit poster's website Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 19 Jun 2005, 11:41
Privalov wrote:
Again the new "struct" macro will take care of it for you automatically.


Ok. Explain me, please, how to use this new "struct" macro to define initialized structured data in data section.

Thanks.
Post 19 Jun 2005, 11:41
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 19 Jun 2005, 11:46
Post 19 Jun 2005, 11:46
View user's profile Send private message Visit poster's website Reply with quote
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 20 Jun 2005, 10:03
I have one more question.

To implement polymorphism in TASM I declare, for example virtual method table as follows:

TABLE Table_CUnknown {
virtual QueryInterface = CUnknown_QueryInterface
virtual AddRef = CUnknown_AddRef
virtual Release = CUnknown_Release
}

Then if I want to inherit this table I write:

TABLE Table_CMyObject {
Table_CUnknown ; <--- inherit from Table_CUnknown
virtual Release = CMyObject_Release; <--- Replace implementation of Release
}

And then I define this tables in data section:

DATASEG
LABEL TableAddr_CUnknown
Table_CUnknown {?}

LABEL TableAddr_CMyObject
Table_CMyObject {?}

Is FASM somehow support such polymorphism?
Post 20 Jun 2005, 10:03
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 20 Jun 2005, 12:05
Some OOP macros would be needed - I haven't designed any such packages yet, though there were some floating around made by others - but I suppose the really good implementations will come after utilizing the newly added preprocessor features (which already allowed to implement the mentioned "struct" macro for example), since these features are so new, it may take some time.
Post 20 Jun 2005, 12:05
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 23 Jun 2005, 01:24
Poor Privalov... so many questions to answer for one person, but he never complains, even if the questions are "stupid" (like mine are).
Post 23 Jun 2005, 01:24
View user's profile Send private message AIM Address 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.