flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
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 |
|||
![]() |
|
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? |
|||
![]() |
|
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. |
|||
![]() |
|
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. |
|||
![]() |
|
THEWizardGenius 17 Jun 2005, 04:03
Quote:
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. |
|||
![]() |
|
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.
|
|||
![]() |
|
afw2004 17 Jun 2005, 09:54
vid wrote: 1. most native way 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"? |
|||
![]() |
|
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.
|
|||
![]() |
|
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 |
|||
![]() |
|
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
|
|||
![]() |
|
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)? |
|||
![]() |
|
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).
|
|||
![]() |
|
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. |
|||
![]() |
|
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. |
|||
![]() |
|
Tomasz Grysztar 19 Jun 2005, 11:46
Read this thread: http://board.flatassembler.net/topic.php?t=3619
|
|||
![]() |
|
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? |
|||
![]() |
|
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.
|
|||
![]() |
|
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).
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.