flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Undocumented(?) preprocessor features

Author
Thread Post new topic Reply to topic
gmg1812



Joined: 15 Aug 2014
Posts: 13
Location: Northern New York
gmg1812 14 Sep 2015, 16:30
There can be more than one symbol in a macro definition ending with [...] and initial values are permitted.
Code:
macro m [a=1,b] { db a,b }
 m ,2,3,4    

generates
Code:
  db 1,2
  db 3,4    

That is, the macro call parameters are handled in pairs with the first ref to "a" having an initial value. This is caused by the definition/call parameter matching process which restarts the definition parameter scan (within the []) until there are no more unprocessed macro call parameters. In this case, obviously the macro call must have an even number of parameters, and at least two.

Text (tokens) appearing after the "}" ending a macro/struc/rept/match/irp/irpv/irps block are considered to be on a new line. For example:
Code:
 rept 5 a {db a} mov eax,1    


I don't believe either action is documented.
Post 14 Sep 2015, 16:30
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 14 Sep 2015, 23:43
gmg1812
Do you really read the documentation? Everything you named is documented very well. There are undocumented features, but you didn't hit one yet.

As for the set of features you enumerated at the beginning, it's unclear what exactly you mean: grouping of arguments with square brackets, repetitive processing of the groups and default values are all documented in 2.3.3 Macroinstructions. You don't expect people to copy-paste here the whole section, do you? Processing of tokens after a closing brace is there as well:
2.3.3 Macroinstructions wrote:
there is one more feature which helps in such cases. Namely it is possible to put any directive, instruction or macroinstruction just after the } character that ends the macroinstruction and it will be processed in the same way as if it was put in the next line.


Quote:
In this case, obviously the macro call must have an even number of parameters, and at least two

It's not obvious and not true. A macro invocation can have any number of arguments unless there are mandatory arguments indicated by an asterisk. Well... And the number of the arguments cannot exceed the number of formal parameters for macros with no grouping. This is obvious indeed.

_________________
Faith is a superposition of knowledge and fallacy
Post 14 Sep 2015, 23:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.