flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Explanation needed

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 13 Dec 2004, 11:39
Hello, everybody!
I have written some macroses, but it doesn't work as I expected.
Maybe you can help me?

So, macroses:

macro M0_
{
display 'Hello from macro M0_',13,10
}

macro M1_
{
display 'Hello from macro M1_',13,10
}

macro M2_
{
display 'Hello from macro M2_',13,10
enable_callmacroses
callmacroses M0
purge callmacroses
}

macro enable_callmacroses
{
macro callmacroses [_macro]
\{
\forward
_macro#_ ; <- it doesn't work here
\}
}

macro callmacroses [_macro]
{
forward
_macro#_ ; <- but here it works
}

callmacroses M1,M2

after compiling I get this message:

illegal instuction _macro_

Somebody,please, explain me why it is so.
Thanks.

_________________
Flat Assembler is the best!
Post 13 Dec 2004, 11:39
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 13 Dec 2004, 12:58
The # symbol is processed when defining the "enable_callmacroses" macro, so inside the "callmacroses" macro you get the:
Code:
_macro_    

line, instead of
Code:
_macro#_    

which is what you want. In order to get the correct line in definition of "callmacroses" macro, put this line in the "enable_callmacroses":
Code:
_macro\#_    


Last edited by Tomasz Grysztar on 12 Jun 2005, 09:30; edited 1 time in total
Post 13 Dec 2004, 12:58
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 13 Dec 2004, 13:33
Thank you very much, Privaliv. And excuse me, please, for not paying enough attention to your FASM programmers manual (by the time I read your answer I had already found explanation in manual). I want to use this trick in creating macroses for OOP with multiple inheritance. To tell the truth, I has already written such macroses but in another way, and it takes a lot of time for compilation. Especially it is when I declare classes with 3 or 4 levels of inheritance or with multiply inheritance. I think that when I rewrite my macroses with useng this trick, they will be compiled faster, but I have suggestion: in the source code of FASM I found that such function as VirtualAlloc is used for memory allocation (I speak about FASM fo Win32), and this function is very slow. Is it possible to replace this function with faster one (HeapAlloc or LocalAlloc),of course,if it isn't hard for you,Privalov?
Thanks again for your explanation.

_________________
Flat Assembler is the best!
Post 13 Dec 2004, 13:33
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 13 Dec 2004, 14:18
Doesn't FASM do it's memory allocation once, grabbing a whole big block of memory and then managing that block itself? In that case, VirtualAlloc is plenty fast, and preferable to the other memory allocation methods.
Post 13 Dec 2004, 14:18
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 13 Dec 2004, 18:09
Yes, it does a single one allocation.
The explanation could be a massive text substitution due to deep nested macros.
Post 13 Dec 2004, 18:09
View user's profile Send private message Yahoo Messenger 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.