flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > about use macro in struc |
Author |
|
vid 18 May 2004, 18:11
i quess it is because macro contents are preprocessed before preprocessing '#' operator, so it won't take ".#type type" as usage of structure (it is not symbol followed by structure name, but it is symbol followed by "#" followed by symbol followed by structure name).
i am not sure if this is really the matter. |
|||
18 May 2004, 18:11 |
|
Tomasz Grysztar 18 May 2004, 18:23
It wouldn't matter if it was inside the structure, because it would anyway be processed as "StrucName.#type" and then concatenated into "StrucName.type". The problem is that dot is used inside the macroinstruction, where it has no special meaning. The structure-specific substitutions are done before doing anything else (if you use "mv .x,.TPoint" macro inside the structure, it will be processed as "mv StrucName.x,StrucName.TPoint"). But in this case, "mv x,TPoint" macro makes just ".x" and ".TPoint" symbols.
|
|||
18 May 2004, 18:23 |
|
zjlcc 19 May 2004, 07:16
thanks reply
(if you use "mv .x,.TPoint" macro inside the structure, it will be processed as "mv StrucName.x,StrucName.TPoint"). But in this case, "mv x,TPoint" macro makes just ".x" and ".TPoint" symbols. Code: format PE GUI 4.0 entry start macro vv main,base,type{ ;vv TRect,TRect.x0,TPoint virtual at base ;virtual at TRect.x0 main#.#type type ; TRect.TPoint TPoint end virtual ;end virtual } struc TPoint { .x dw 0 .y dw 0 } virtual at 0 TPoint TPoint end virtual struc TRect { .x0 dw 0 .y0 dw 0 vv TRect , .x0 , TPoint ;<== OK!! } virtual at 0 TRect TRect end virtual ;RR TRect ;<==if use it then report error Else OK!!!!! start: ; mov [RR.x0],10h ; mov ax,[RR.TPoint.x] ret err msg: main#.#type type error:symbol already defined |
|||
19 May 2004, 07:16 |
|
Tomasz Grysztar 19 May 2004, 08:40
Your struc macro defines "TRect.TPoint" structure each time it is invoked, so that's why when you use it for the second time you get "symbol already defined" error.
|
|||
19 May 2004, 08:40 |
|
zjlcc 19 May 2004, 11:36
oh,yes!you right
|
|||
19 May 2004, 11:36 |
|
aaro 19 May 2004, 11:42
Are you trying to do union macro? Here's how i did it:
Code: macro _union_declare_data [arg] { forward arg } macro union [arg] { common local ..union_addr, peak ..union_addr: peak = $ forward virtual at ..union_addr _union_declare_data arg if $ > peak peak = $ end if end virtual common rb peak - $ } Usage: Code: struc TVINSERTSTRUCTA { .hParent dd ? .hInsertAfter dd ? union \ .itemex TVITEMEXA,\ .item TVITEMA } struct TVINSERTSTRUCTA |
|||
19 May 2004, 11:42 |
|
zjlcc 22 May 2004, 10:44
thank aaro!
have some like my idea can you see my topic: ? http://board.flatassembler.net/topic.php?t=1607 |
|||
22 May 2004, 10:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.