flat assembler
Message board for the users of flat assembler.
Index
> Main > include directive behavior |
Author |
|
vid 17 Nov 2003, 18:13
Wouldnt it be better to refer to current idea with '.'. SO to do what you want you could just use
Code: include '.\test2.inc' Maybe not '.', it could be problem with OS, but some special symbol, or pseudo-environment variable (like %CurrentFile%). |
|||
17 Nov 2003, 18:13 |
|
aaro 19 Nov 2003, 13:04
In my opinion it should be includes default behavior but something like %CurrentDir% would also do so i could have macro that works like i want.
|
|||
19 Nov 2003, 13:04 |
|
pelaillo 19 Nov 2003, 16:26
It is useful indeed, and not only for includes but for all directory references in fasm (file and load directives).
It could be a fasm directive to indicate reference at current preprocessed file path. AFAIK it cannot be done with only macros (until Privalov proves me wrong ) The result could be similar to the time directive (%T) that Privalov is including in new release: %T - compile time %D - current parsed file directory %F - current parsed file name |
|||
19 Nov 2003, 16:26 |
|
vid 20 Nov 2003, 19:12
didnt you mean current preprocessed? (not current parsed)
|
|||
20 Nov 2003, 19:12 |
|
aaro 22 Nov 2003, 16:36
If you Privalov see this, would it be difficult to add something like %D to fasm? I would really appreciate it, i'm trying to create macros for somekind of module system and i have structured my projects like this:
Code: ProjectDir: main.asm main.inc foobar.asm Module1: main.asm main.inc foo.asm bar.asm SubModule: main.asm main.inc Module2: main.asm main.inc |
|||
22 Nov 2003, 16:36 |
|
vid 23 Nov 2003, 14:21
aaro: why .inc files? You compile to OBJ files and link then? If you just include everything into one file and assemble then i dont see reason for separate .inc files. And if not, why do you need %D then?
do not take this as offense, i was just wondering why you use them |
|||
23 Nov 2003, 14:21 |
|
Vortex 23 Nov 2003, 14:54
vid,
The main feature of Fasm is that it can produce executables without the usage of object files,in another way,you don't have to use an external linker. Naturally,depending on the project, one can select the classical method based on creating obj files. _________________ Code it... That's all... |
|||
23 Nov 2003, 14:54 |
|
Tomasz Grysztar 23 Nov 2003, 18:47
I have designed very interesting macro solution (fasm 1.49.9.2 or higher is needed, as it uses the concatenations of quoted strings, which was not enabled in earlier versions):
Code: macro incdir dirpath,filename { macro rstincdir .% inc_dir fix cur_dir %. cur_dir fix cur_dir # '\' # dirpath } macro endinc { rstincdir purge rstincdir } macro defincl { macro incl filename .% defincl INCLUDE inc_dir .. '\' .. filename purge incl %. } include fix incl inc_dir fix cur_dir cur_dir fix '.' .% fix { %. fix } .. fix __ __ fix # defincl Here's an example of usage: Code: include 'foobar.inc' ; includes .\foobar.inc incdir 'module1' include 'foo.inc' ; includes module1\foo.inc include 'bar.inc' ; includes module1\bar.inc endinc and file "module1\foo.inc" may contain something like: Code: include 'subfoo.inc' ; includes module1\subfoo.inc incdir 'submod1' include 'x.inc' ; includes module1\submod1\x.inc endinc |
|||
23 Nov 2003, 18:47 |
|
aaro 23 Nov 2003, 21:23
Privalov: Thank you VERY mutch! Just what i needed.
vid: I like the ability in fasm to assemble without linking and i use separate .inc/.asm files just to organise my code. With these macros i can now have my modules in sub dirs under my project dir and if i need that module in some other project i just copy the sub dir in the new project folder. Then if i need to change something in my module it won't break my old code. |
|||
23 Nov 2003, 21:23 |
|
vid 24 Nov 2003, 05:48
vortex: i know, i was just asking him which method he uses
aaro: i use modules too (for reusuability, but i never reused anything, i rather rewrite it better). But in assermbly there's not separate declaration and definition like in C, and i only break my module file when they are is too big to maintain. But, of course, code as you like. |
|||
24 Nov 2003, 05:48 |
|
aaro 27 Nov 2003, 02:27
Privalov, is it possible to get these macros work with paths outside the project dir? Now i have to use old include with paths like: '%include%\win32a.inc' and incl with others(commented line 'include fix incl'). Not very importan(i can live with it) but it would be nice if it worked with those too. I can't think way to accomplish this, but it wouldn't be first time you show me how to go around these obstacles.
And in macro 'incdir' there is paramater called 'filename' witch is never used, probably some leftover from previous version, just to inform you. |
|||
27 Nov 2003, 02:27 |
|
Tomasz Grysztar 27 Nov 2003, 15:33
You can try such little modified version:
Code: macro incdir dirpath { macro rstincdir .% inc_dir fix cur_dir %. cur_dir fix cur_dir # dirpath } macro endinc { rstincdir purge rstincdir } macro defincl { macro incl filename .% defincl INCLUDE inc_dir .. filename purge incl %. } include fix incl inc_dir fix cur_dir cur_dir fix '' .% fix { %. fix } .. fix __ __ fix # defincl It should allow normal include use, and the only difference is that you should include path separator at the end of path for "incdir" macro, like: Code: incdir 'module1\' include 'foo.inc' include 'bar.inc' endinc |
|||
27 Nov 2003, 15:33 |
|
aaro 27 Nov 2003, 17:36
Won't work in modules(incdir has been called). I can't think any other solution to this but to somehow compare start of file name with '%include%' and '\' but i don't think that's possible.. I hope i'm mistaken.
|
|||
27 Nov 2003, 17:36 |
|
Tomasz Grysztar 27 Nov 2003, 17:59
Do you mean that you need to do use %include%-like includes in the submodules? Indeed, that would be harder. But you can always use the uppercase INCLUDE for such purpose (or: Include) - it will invoke the original one, not macro.
|
|||
27 Nov 2003, 17:59 |
|
aaro 27 Nov 2003, 19:53
Yes that's what i meant. Harder, but not impossible?
But it's good enought allready, i'll use INCLUDE when i want normal behavior. Thank you. |
|||
27 Nov 2003, 19:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.