flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > Why does FORWARD/REVERSE always get processed? |
Author |
|
revolution 01 Sep 2010, 03:35
It is easier to exclude expressions than having to duplicate them.
Code: ;... common if ~ y eq forward display '-' common end if ;... |
|||
01 Sep 2010, 03:35 |
|
bitRAKE 01 Sep 2010, 03:57
Code: abc abc , abc ,, abc ,,, Code: - -- --- ---- |
|||
01 Sep 2010, 03:57 |
|
revolution 01 Sep 2010, 05:38
bitRAKE wrote: (No such thing as a macro without parameters if defined to take parameters.) |
|||
01 Sep 2010, 05:38 |
|
Tomasz Grysztar 01 Sep 2010, 06:55
bitRAKE wrote: [Logically, it seems the forward section of the macro shouldn't get processed if there are no parameters to iterate through. |
|||
01 Sep 2010, 06:55 |
|
bitRAKE 02 Sep 2010, 01:30
Empty is good, but having no value could be a 'feature' (i.e. added confusion). "*" is used if a macro must have a value, and it's possible to pass an empty value differently than no value. It is only the present interpretation of the macro definition which limits the use - "y" is a placeholder which the present definition says defaults to empty - not undefined.
Code: macro xyz { forward display "-" reverse display "|" common display 13,10 } Code: macro abc [y] { common if ~ y eq forward display '-' display `y common end if display 13,10 } t equ abc t abc a abc a,b Code: macro abc [y*] { } t equ abc ; invalid macro argument - empty not valid abc t ; empty seems okay abc a ; not having a definition is okay _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
02 Sep 2010, 01:30 |
|
baldr 02 Sep 2010, 05:03
bitRAKE wrote: Here we have an actual empty value in "t" passed as a parameter. Preprocessed listing is priceless. |
|||
02 Sep 2010, 05:03 |
|
bitRAKE 02 Sep 2010, 06:14
I'm trying to address the preprocessor language and not a specific programming problem.
Sorry, for being so vague. |
|||
02 Sep 2010, 06:14 |
|
Tomasz Grysztar 02 Sep 2010, 06:55
bitRAKE wrote: I'm trying to address the preprocessor language and not a specific programming problem. It is related to how the language is defined, not the particular implementation. To define such fine details of language I once wrote the Order of processing section of manual (and I plan to expand the topic in Understanding fasm). It is important that those rules really are (and have to be) a part of the language, and may still be implemented in a various ways. Last edited by Tomasz Grysztar on 02 Sep 2010, 21:16; edited 1 time in total |
|||
02 Sep 2010, 06:55 |
|
Tomasz Grysztar 02 Sep 2010, 08:03
Back to the original question - there is one more interesting detail.
If you had this simple macro: Code: macro data x { db x } Code: macro data [x] { db x } This macro works exactly the same as the first one, unless more than one parameter is provided. This includes, that it works exactly the same as the first one when empty value for this one parameter is provided. |
|||
02 Sep 2010, 08:03 |
|
Tomasz Grysztar 02 Sep 2010, 08:13
bitRAKE wrote: "y" is a placeholder which the present definition says defaults to empty - not undefined. No, there is no "default" in present definition. You get the empty value because you provide the empty value when you use the macro. Like: Code: abc ; one empty parameter abc , ; two empty parameters abc ,, ; three empty parameters, etc. This could be changed in the future to "when parameter has an empty value, the default value is taken instead", and only this way the concept of "default" could get introduced here. And the fact that single empty parameter is in text indistinguishable from no parameters at all (which is interpretation accepted when macro is defined to take no parameters) is merely a conincidence. bitRAKE wrote: Here forward/reverse have no meaning and are processed anyhow - there is no parameter to iterate through. Note that "forward" and "common" will work this way even in case of "match" directive - when there is also an option of one iteration or zero iterations, depending on whether there is a match, or none. This relates to the fact that those directives are universal for all macro-builders, like "macro", "rept", "irp", "irps" and "match" and they are connected to the amount of iterations specified for that macro. Even if you do "rept" without any counter, you can still create symbols to iterate through - with the "local" directive: Code: rept 4 { local a a: dd a common db a ; aggregates "a" values from four iterations } This all should get covered in "Understanding fasm", of course. |
|||
02 Sep 2010, 08:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.