flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > struc { .macro } -- bug?

Author
Thread Post new topic Reply to topic
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
Hi!

This code works without any problems (as expected):
Code:
macro foo {  }
struc bar {foo}
bar bar    

But this does not:
Code:
macro .foo {  }
struc bar2 {.foo}
bar2 bar2 

bar2.foo      Error: illegal instruction
    


Is this normal?
macros with DOT prefix works well in all other places in the source. Crying or Very sad
Post 19 Mar 2004, 12:29
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
of course, it is preprocessed to
bar2.foo
which is not instruction or directive
maybe you meant.
struct bar2 {.foo:}
(note ":") which will declare label.
Post 20 Mar 2004, 09:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
Quote:
maybe you meant.
struct bar2 {.foo:}

No, I'm trying to use a macro, which name is started with the dot.
This macro is to generate some local labels predefined earlier.

Of cource, it's not hard to change the name of the macro (for example, just remove the dot), but I expect it should be preprocessed (like in the first variant) to:
Code:
 bar2 {body of the macro .foo}     

I suppose the dot has special meaning inside the "struc" clause in this case, but it seems a bit illogical for me:
We can declare a macro and use it everywhere in the source.
But when its name is started with dot, the "struc" clause is the only exclusion from common rule.
FASM.TXT wrote:
All the rules concerning standard macroinstructions apply to structure macroinstructions.
Post 20 Mar 2004, 11:14
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7318
Location: Kraków, Poland
It's just a matter of priority. In the same way when you define macro of some name, and use another macro with parameter of the same name:
Code:
macro alpha { }
macro beta alpha { alpha }    

then when you do:
Code:
beta nop    

you'll of course get NOP instruction processed, because all macro processing is done before anything else (like recognizing directives or other macros). This is substantial for the macro mechanism to become really usable. And processing symbols starting with dot before doing anything else with them is just one more aspect of this behaviour.
Post 20 Mar 2004, 11:42
View user's profile Send private message Visit poster's website Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
Thanks for explanation, Privalov
now I understand it isn't a bug I was afraid before.

In other words, if inside struc clause there is any name starting with dot, then it's interpreting like local label name unambiguously, but not a macro.

This is, probably, because struc and macro are used in different ways:
(and FASM needs to differ them, because they may have the same name)
Code:
macro      .foo {  }
struc    bar {.foo}
macro   bar {.foo}
some:
   bar
other    bar     ;;  this won't work becouse of .foo
    

So, it's better don't abuse dots (like me), instead of losing some other very nice capabilities Smile

Really, there are lots of symbols on my keyboard Very Happy
Post 20 Mar 2004, 16:06
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7318
Location: Kraków, Poland
Also you can define and use some macro local to your structure this way, like:
Code:
struc foo
{
  macro .bar _% %_
  .bar ; we use the above macro here
}

_% fix {
%_ fix }    

If you do "some foo", it will define "some.bar" macro and use it, and it works because of the behavior pointed out by you.
Post 20 Mar 2004, 16:09
View user's profile Send private message Visit poster's website Reply with quote
pas



Joined: 16 Aug 2003
Posts: 17
Location: Russia
You want to change names macro dynamically on the certain pattern?
Such as to create macro:
CLB Name, Name1
And to use:
Name. Create
Name1. Create
And ò. ä.?
If yes I can send macro of creation of an element of management such as CheckListBox.
The announcement of elements of management:
CheckListBox 206, List, 207, List2
Creation of elements of management
List. Create
List2. Create
Post 23 Mar 2004, 02:04
View user's profile Send private message Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
Privalov, thanks for excellent example of this very powerful feature Smile
I think it could be REALLY useful, for example, to define some advanced kind of "comcall" macro Cool


pas, thanks, now I see how it works ^^ Smile
Post 23 Mar 2004, 11:02
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
sorry for my mistake, i havent noticed "macro .foo {}"

Just to add, structure name will be appended not only to labels starting with dot, but to every symbol starting with dot, even .45 (which is elsewhere valid FP number)
Post 23 Mar 2004, 19:38
View user's profile Send private message Visit poster's website AIM Address 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-2019, Tomasz Grysztar.

Powered by rwasa.