flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] How to issue unique labels in macro calminstruction? |
Author |
|
fabbel 21 Sep 2023, 10:55
... Sub-question : how is the line 'local @empty, @cont' processed ?
... i.e : * is it treated as locals definition at macro calminstruction?.dispsymbol? level ? * or conversely, is it only 'blindly' including such line within calminstruction test body - thereby creating corresp. locals within calminstruction test ? ( obv not the intent here .... ) |
|||
21 Sep 2023, 10:55 |
|
Tomasz Grysztar 21 Sep 2023, 12:21
In current implementation LOCAL in context of CALM definition is always seen as CALM command, not as a macro directive of the same name. This makes it impossible to create macro local symbols in such context. There are some quirks in the engine that make it hard to change, so until I find a solution please consider it an undefined behavior.
To generate unique labels, you would therefore need to make a "calminstruction calminstruction?.dispsymbol?" instead, and generate labels with numeric suffix, etc. |
|||
21 Sep 2023, 12:21 |
|
Tomasz Grysztar 21 Sep 2023, 13:25
I prepared a very simple framework that you could use to automatically generate unique symbols inside CALM definitions:
Code: include 'xcalm.inc' define loc? loc? calminstruction calminstruction?.new? name* local new, i init i, 0 compute i, i+1 arrange new, name#i arrange name, loc.name publish name, new end calminstruction calminstruction calminstruction?.@? statement& transform statement, loc assemble statement end calminstruction macro calminstruction?.dispsymbol? sym match , sym new @empty @ jyes @empty display '<not empty>' new @cont @ jump @cont @ @empty: display '<empty>' @ @cont: end macro calminstruction test arg1, arg2 display '> arg1: ' dispsymbol arg1 display 13 display 10 display '> arg2: ' dispsymbol arg2 display 13 display 10 end calminstruction |
|||
21 Sep 2023, 13:25 |
|
fabbel 21 Sep 2023, 13:36
tx for feedback ...
... however, regarding : Quote:
.... I already considered this.. but I see name collisions may occcur nonetheless ... it seems labels are just plain names w/o any context or namespace separation - no ? (typ. can't include dot '.') ? ....typ., assuming"calminstruction calminstruction?.dispsymbol?" happens to generate e.g. label '@empty_1', can fasmg differentiate that from a label '@empty_1' that calminstruction test may also define for its own purpose ? (... need to be 'agnostic' to internal impl of "calminstruction calminstruction?.dispsymbol?") |
|||
21 Sep 2023, 13:36 |
|
Tomasz Grysztar 21 Sep 2023, 15:20
fabbel wrote: can fasmg differentiate that from a label '@empty_1' that calminstruction test may also define for its own purpose ? Another solution could be to make a complete CALM preprocessor with help of unconditional interceptor, to rewrite entire definition on your own terms - then you could, for example, use a different prefix for user-defined names, and different one for synthesized ones. |
|||
21 Sep 2023, 15:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.