flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > including files |
Author |
|
cod3b453 21 Jan 2012, 11:35
There is a difference between using "_file3 = 1" and "_file3 equ 1"; defined only works on the last one, so if you use that it should work.
|
|||
21 Jan 2012, 11:35 |
|
JohnFound 21 Jan 2012, 11:56
It is not so easy task. Here is my attempt to do this.
Compile the file "MainUnit.asm" [EDIT]Sorry, but the example is not working with the current versions of FASM. I will remove the attachment.[/EDIT] |
|||
21 Jan 2012, 11:56 |
|
Ariethenor 21 Jan 2012, 12:18
cod3b453:
I understand what you are saying, but it unfortunately is not the reason. I understand the reason my code will not work, it is because it tests for initial define, and my dummy define "_file3=1" if it gets processed once it will define the dummy and will always get defined again. This is because of the OR " | " test. I was wondering if there was some way to construct some kind of XOR test if it would work, but I can't figure how to properly XOR. This is the infinite loop problem discussed in the user manual. JohnFound: Does your code work, or is it just another avenue of thinking to help solve the problem? |
|||
21 Jan 2012, 12:18 |
|
JohnFound 21 Jan 2012, 12:23
The code (I removed) was created with older version of FASM and uses the old behavior of "fix" directive. In the latest versions these tricks does not work anymore.
Though, the idea is valid - create the list with unique names of the modules and then include them at once. The macro "uses" just adds the module name to the list if it is not already there. Last edited by JohnFound on 21 Jan 2012, 12:56; edited 1 time in total |
|||
21 Jan 2012, 12:23 |
|
Ariethenor 21 Jan 2012, 12:32
To get around this problem for now, I am kind of doing that manually, I comment all the dependent files in the modules, and for each prog1.asm i have a prog1.inc that i input all the include files manually so that all gets the required includes once and only once. However it is a pain in the arse, and it would be nice to be able to do it auto"magically". There has to be a way, but it seams that because of the way the assembler preprocesses, it may actually be impossible, because it will always treat the first include file reached on the first pass as a second or third time etc. on the second pass and therefore will not redefine it etc, thus the infinite loop.
|
|||
21 Jan 2012, 12:32 |
|
cod3b453 21 Jan 2012, 13:04
This is my test code X includes A,B which both include C; C is only assembled once.
|
|||||||||||
21 Jan 2012, 13:04 |
|
Ariethenor 21 Jan 2012, 13:37
Solution:
All include files must be like this: if ~ defined FILE3_INC | defined @f ; can use any name unique to the included file FILE3_INC: ; must be same as above @@: (source here) end if this works on FASM ver: 1.69.35 |
|||
21 Jan 2012, 13:37 |
|
Tomasz Grysztar 23 Jan 2012, 11:52
Similar question was asked already on the board a few times, there was "includeonce" macro provided in the answer:
http://board.flatassembler.net/topic.php?t=4587 http://board.flatassembler.net/topic.php?p=106846#106846 (revolution's improved version that allows nesting) EDIT: I found out that this macro is also provided in this nice post about "Principles for creating multi-developer programs with fasm": http://board.flatassembler.net/topic.php?t=8309 |
|||
23 Jan 2012, 11:52 |
|
uart777 23 Jan 2012, 17:03
[ Post removed by author. ]
Last edited by uart777 on 17 Nov 2013, 00:25; edited 1 time in total |
|||
23 Jan 2012, 17:03 |
|
l_inc 23 Jan 2012, 18:32
[include duplication ]
Last edited by l_inc on 23 Jan 2012, 18:38; edited 1 time in total |
|||
23 Jan 2012, 18:32 |
|
l_inc 23 Jan 2012, 18:38
Tomasz Grysztar wrote: Similar question was asked already on the board a few times, there was "includeonce" macro provided in the answer This is not a very comprehensive solution, because it misses situations when an include file is included in different ways which is actually a common situation even if all include-strings are relative and lowercased. I'd appreciate a fasm feature allowing to resolve such situations. Anyway disregarding this problem I'd still prefer to overload the original include directive rather than using a differently named macro, because it allows to keep track on including standard (and also other) headers which use the include directive directly: Code: ;Prevents includes duplication include fix include_directive_modified include_directive_original fix include included_files_list equ 'includecheck.inc' display "'",'includecheck.inc',"'",' included',13,10 include_file_output_indentation equ '' macro def_include_directive_modified { macro include_directive_modified arg* \{ define matched - match leader arg trailer,'' included_files_list '' \\{ restore matched define matched + display 'Warning: ',"'",arg,"'",' duplication',13,10 \\} match -,matched \\{ display include_file_output_indentation,"'",arg,"'",' included',13,10 tmp equ included_files_list restore included_files_list included_files_list equ tmp arg restore tmp def_include_directive_modified include_file_output_indentation equ include_file_output_indentation,' ' include_directive_original arg restore include_file_output_indentation purge include_directive_modified \\} restore matched \} } def_include_directive_modified As a bonus you also have an include-tree displayed: Code: include 'includecheck.inc' include 'includecheck.inc' include 'win32a.inc' include 'general.inc' include 'macro/resource.inc' include 'hexencode.inc' ... produces Code: 'includecheck.inc' included Warning: 'includecheck.inc' duplication 'win32a.inc' included 'macro/struct.inc' included 'macro/proc32.inc' included 'macro/com32.inc' included 'macro/import32.inc' included 'macro/export.inc' included 'macro/resource.inc' included 'equates/kernel32.inc' included 'equates/user32.inc' included 'equates/gdi32.inc' included 'equates/comctl32.inc' included 'equates/comdlg32.inc' included 'equates/shell32.inc' included 'equates/wsock32.inc' included 'general.inc' included Warning: 'macro/resource.inc' duplication 'hexencode.inc' included |
|||
23 Jan 2012, 18:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.