flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > two dots & default parameter value

Author
Thread Post new topic Reply to topic
flat_user



Joined: 01 Jun 2010
Posts: 13
flat_user 13 Jun 2010, 00:38
Quote:
If the name given as parameter to local directive begins with a dot or two dots, the unique labels generated by each evaluation of macroinstruction will have the same properties.

1. What exactly does that mean?
Where's the difference when I write 'local ..num'?

2. Can I somehow give a macro-parameter a default value like this:
Code:
macro testmacro reg, val=1
{
  mov reg,val
}

testmacro eax
testmacro ebx,2    

or like this:
Code:
struc POINT x, y
{
  .x dd x
  .y dd y
}

mypoint1 POINT 1, 2  ;x=1 y=2
mypoint1 POINT 1     ;x=1 y=uninitialized
mypoint1 POINT , 2   ;x=uninitialized y=2    

thanks!
Post 13 Jun 2010, 00:38
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 13 Jun 2010, 19:43
flat_user wrote:
Quote:
If the name given as parameter to local directive begins with a dot or two dots, the unique labels generated by each evaluation of macroinstruction will have the same properties.

1. What exactly does that mean?
Where's the difference when I write 'local ..num'?
Exactly it means that FASM appends unique suffix to the symbol you've supplied as argument for local macro-directive.
If you use that symbol to define label, its properties will be the same as for prefix only: .name: will be local, ..name: and name: will be global (but former won't define new prefix for local labels).
flat_user wrote:
2. Can I somehow give a macro-parameter a default value like this:
Macro arguments that aren't marked as required can be empty. match instant-macro and eq operator of if directive can be used to check for this.
Post 13 Jun 2010, 19:43
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 08 Jan 2012, 22:08
How do you actually do this? I tried a few things, but I can't get anything to work:


Code:
if codename eq
\codename=".text"
end if

if ~ defined bssname
\bssname=".bss"
end if

match   =bssname, bssname {\bssname=".bss"}    

_________________
This is a block of text that can be added to posts you make.
Post 08 Jan 2012, 22:08
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 15 Jan 2012, 08:00
mindcooler: What is the backslash supposed to achieve?

Also, the equals (=) is an assembly time assignment for numeric values. And "match" is preprocessor time processing. It is generally not possible to mix the two together unless you really know what you are doing with a great degree of confidence.
Post 15 Jan 2012, 08:00
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 15 Jan 2012, 08:02
I thougt that escaping the variable would mean the variable, and not its value.

I'm not mixing, those are all different attempts of doing the same thing.
Post 15 Jan 2012, 08:02
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.