flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Include only once problem.

Author
Thread Post new topic Reply to topic
halyavin



Joined: 21 Aug 2004
Posts: 42
halyavin
I have complex nesting include directives. Sometimes the same file included twice. But this leads to errors. What is the best solution for this problem when file contains macroses and when it doesn't?
Currently I use
Code:
if ~defined file_inc
file_inc_fix:
file_inc fix file_inc_fix ;fix requires less memory than equ
;actual code...
end if
    

when file doesn't contains macroses.
Post 06 Jan 2006, 08:20
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7489
Location: Kraków, Poland
Tomasz Grysztar
Read the answer to fourth question in the FAQ and the section 2.3.7 of the manual (I feel like deja vu).

As for your particular problem, this macro will include each file only once, but only if the path given for such file is exactly the same each time (it's case sensitive):
Code:
macro includeonce path
{
 file@include equ path
 match head path tail,files@included
 \{ file@include equ \}
 match head path,files@included
 \{ file@include equ \}
 match file, file@include
 \{ include file \}
 files@included equ files@included path
}    


PS. Do not overuse FIX directive - it is no longer to widely used, the section 2.3.7 might explain to you, why.
Post 06 Jan 2006, 08:54
View user's profile Send private message Visit poster's website Reply with quote
halyavin



Joined: 21 Aug 2004
Posts: 42
halyavin
Thanks for this macro idea. It can be improved (if necessary) a little:
Code:
macro includeonce [path]
{
reverse
 file@include equ path 
forward
 match head path tail,files@included 
 \{ file@include equ \} 
 match head path,files@included 
 \{ file@include equ \} 
 match path tail, files@included
 \{ file@include equ \}
 match path,files@included
 \{ file@include equ \}
common
 match file, file@include 
 \{ include file \} 
forward
 files@included equ files@included path 
}    

for using as includeone "real path","mirror1","mirror2"
PS When fix disappear from fasm syntax I manually execute "fix fix equ" command for my source files Wink .
Post 06 Jan 2006, 09:53
View user's profile Send private message Visit poster's website 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.