flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Struct implementation question... |
Author |
|
vid 03 Mar 2006, 10:22
same way as earlier, but proper way is (and was):
Code: struc Rec { .Val1 dd ? .Val2 dd ? } virtual at 0 Rec Rec sizeof.Rec = $ - Rec end virtual |
|||
03 Mar 2006, 10:22 |
|
Tomasz Grysztar 03 Mar 2006, 11:25
The "struct" macro defines all the offsets automatically, see documentation.
|
|||
03 Mar 2006, 11:25 |
|
IronFelix 03 Mar 2006, 13:36
I know it, Tomasz, it is very powerful macro, thank you, but i need to do it with 'struc' manually.
Thanks and regards. |
|||
03 Mar 2006, 13:36 |
|
Tomasz Grysztar 03 Mar 2006, 14:07
Sorry, I misunderstood your question. Note that except for the "fix" (and some other minor changes) fasm keeps all the old features.
|
|||
03 Mar 2006, 14:07 |
|
IronFelix 06 Mar 2006, 06:39
Tomasz, please explain, why this doesn't work and. if it is not hard for you, explain your "struct" macro implementaion. It will be very helpful i think.
Code: macro ins_field [Name] { forward .#Name dd ? } struc A { ins_field a,b,c } struc B { .aa A ins_field a,b,c } a A b B Thanks. _________________ Flat Assembler is the best! |
|||
06 Mar 2006, 06:39 |
|
Tomasz Grysztar 06 Mar 2006, 08:49
The preceding of dotted symbols by structure name is done only in the lines generated by the structure macro itself - the child macros invoked then by those lines are already independent (thus you can always be sure that with regular macro the symbol starting with dot will stay what it is).
Thus it should be rather done like Code: macro ins_field Struc,[Name] { forward Struc#.#Name dd ? } struc A { ins_field .,a,b,c } struc B { .aa A ins_field .,a,b,c } a A b B As for the "struct" macro explanation, please give me some more time. |
|||
06 Mar 2006, 08:49 |
|
IronFelix 06 Mar 2006, 09:37
Thanks for so quick reply!
As for the time - as much as you need of course Thanks again, will try to use your answer in my OOP macroses. |
|||
06 Mar 2006, 09:37 |
|
IronFelix 06 Mar 2006, 12:12
Tomasz, excuse me for so much questions, but please explain, how must be implemented such thing:
Code: macro ins_field str,[Name,Type,Value] { forward str#.#Name Type Value } struc A { ins_field .,a,dd,?, b,dd,? ,c,db,? } struc B { ins_field ., aa,A,, a,dd,?, b,dd,? ,c,db,? ; <- try to declare uninitialize structure here } a A b B Thanks. _________________ Flat Assembler is the best! |
|||
06 Mar 2006, 12:12 |
|
IronFelix 06 Mar 2006, 13:36
Solve this problem, just remember about "enable_xxx" and "purge xxx" technique. But have got another one: why doesn't work this:
Code: macro enable_ins_field { macro ins_field str,[Name,Type,Value] \{ \forward str\#.\#Name Type Value \} } enable_ins_field macro A_ins { ins_field .,a,dd,?, b,dd,?, c,db,? } struc A { enable_ins_field A_ins purge ins_field } macro B_ins { ins_field .,aa,A, , a1,dd,?, b1,dd,?, c1,db,? } struc B { enable_ins_field B_ins purge ins_field } a A b B Thanks. _________________ Flat Assembler is the best! |
|||
06 Mar 2006, 13:36 |
|
IronFelix 09 Mar 2006, 08:33
Hi all!
Have another question: why "sizeof" doesn't work in this case? Code: macro enable_ins_field { macro ins_field str,[Name,Type,Value] \{ \forward str\#.\#Name Type Value \} } struc A { macro A_ins \{ ins_field .,a,dd,?, b,dd,?, c,db,? \} enable_ins_field A_ins purge ins_field } struc B { macro B_ins \{ ins_field .,a1,dd,?, b1,dd,?, c1,db,?, aa,A, \} enable_ins_field B_ins purge ins_field } virtual at 0 A A sizeof.A = $ - A end virtual virtual at 0 B B sizeof.B = $ - B end virtual Thanks and regards. _________________ Flat Assembler is the best! |
|||
09 Mar 2006, 08:33 |
|
Tomasz Grysztar 09 Mar 2006, 09:33
When you use the "." symbol inside the STRUC macro, the preprocessor abstains from generating the label for structure automatically and leaves it to you. Thus while using the "." somewhere inside the STRUC macro you need to put something like:
Code: .: or Code: label . in the beginning (or other place you find suitable) of it. This behavior was introduced to allow declaring the "." label in any way you want, not as it is with automatically generated one. |
|||
09 Mar 2006, 09:33 |
|
IronFelix 10 Mar 2006, 06:35
Thank you, Tomasz! FASM is really the best!
Regards. |
|||
10 Mar 2006, 06:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.