flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > [BUG]question about 'match' and 'file' |
Author |
|
revolution 27 Mar 2010, 15:15
file does not enumerate the include environment variable.
|
|||
27 Mar 2010, 15:15 |
|
zhak 27 Mar 2010, 15:18
how is it possible to implement the macro above so that 'file' directive could be used to add files to source code?
thanks in advance |
|||
27 Mar 2010, 15:18 |
|
revolution 27 Mar 2010, 15:20
Change the path so that fasm can find it without needing the include environment variable
|
|||
27 Mar 2010, 15:20 |
|
LocoDelAssembly 27 Mar 2010, 15:20
I don't have that problem here. I've tried with this:
Code: SYS_LANGUAGE equ "Test" match lang, SYS_LANGUAGE { file '.\'#lang#'\test.inc' } Do you have the same problem if you use "file '..\DOCS\HELP\some_lang\COMMAND.HLP"? (some_lang has to be replaced by an existing directory) |
|||
27 Mar 2010, 15:20 |
|
zhak 27 Mar 2010, 15:52
i have the following:
Code: LANGUAGE_ENGLISH equ 'ENG' SYS_LANGUAGE equ LANGUAGE_ENGLISH match lang,SYS_LANGUAGE { include '.\LANG\'#lang#'\CMDLINE.SZ' } this works fine. But if I try Code: match lang,SYS_LANGUAGE { file '.\LANG\'#lang#'\CMDLINE.SZ' } then error 'file not found' occurs. If I use simply Code:
file '.\LANG\ENG\CMDLINE.SZ'
then it compiles OK. |
|||
27 Mar 2010, 15:52 |
|
LocoDelAssembly 27 Mar 2010, 16:19
I'm uploading what I exactly tested under FASMW, please try it.
PS: I'm using FASMW 1.69.12
|
|||||||||||
27 Mar 2010, 16:19 |
|
zhak 27 Mar 2010, 17:35
the problem is that match macro doesn't correctly recognize ..\ (go to parent dir) in path to file
the following example doesn't work:
|
|||||||||||
27 Mar 2010, 17:35 |
|
zhak 27 Mar 2010, 17:51
finally I got it!!!! I don't need to use ..\ in macro.
Code: match lang,SYS_LANGUAGE { file 'DOCS\HELP\'#lang#'\RLDR\COMMANDS\CLR.HLP' } sz_help_mem: file '..\DOCS\HELP\ENG\RLDR\COMMANDS\MEM.HLP' both lines compile OK |
|||
27 Mar 2010, 17:51 |
|
baldr 27 Mar 2010, 20:59
zhak,
I was surprised that your source (attachment from 2010-03-27 19:35) compiled without a hitch. Then I remembered some modifications regarding file and include directives I made to FASM sources not a long time ago… Partly you're right, the problem is related to match directive usage: when file directive is a result of macro expansion (irp / irps / match / rept are instant macros), FASM don't search for the file in the directory that contains included source which originates that file directive (INCL in our case, because it contains test.inc), only the directory of the main source. Here is the mod: Code: open_binary_file: push esi push edi ;;;; ASSEMBLE.INC [1734] ; mov esi,[current_line] ; mov esi,[esi] ;+++ mov eax,[current_line] find_current_source_path: mov esi,[eax] test byte [eax+7],80h jz get_current_path mov eax,[eax+12] jmp find_current_source_path ;=== ASSEMBLE.INC [1736] get_current_path: The last source compiles (you didn't provide entire tree, so I should guess) because 'DOCS\HELP\lang\RLDR\COMMANDS\CLR.HLP' is valid file path relative to your main source. What if your include file was found via %INCLUDE%? P.S. Now I remember: there was the topic A suggestion! ("FILE" and "INCLUDE") about this. |
|||
27 Mar 2010, 20:59 |
|
zhak 27 Mar 2010, 21:25
Thanks baldr,
To compile, i use .BAT script in the source root directory. I don't use %INCLUDE% variable. And yes, you're right, DOCS folder is relative to main source. |
|||
27 Mar 2010, 21:25 |
|
LocoDelAssembly 27 Mar 2010, 21:53
baldr, sorry I don't have my brain turned on today, should I move this to compiler internals and flag it as a bug?
I found really odd the behavior, for me, "file" should have the same path searching method no matter where it came from, after all, the assembler stage should be completely ignorant about the existence of a preprocessor and that fasm has a built-in one should be considered just a coincidence. If fasm wants to make "file" search relative to the source containing it, then it should do so for the same line not included inside any block enclosed by curly braces. In case someone else is lost like I was for a moment, fasm is not realizing that "match" is forming a path, the fail also happens when using a literal string in INCL/test.inc (zhak attachment) Code: match lang,SYS_LANGUAGE { file '..\LANG\ENG\CMDLINE.SZ' } ; Also triggers file not found, but it is OK if you keep match's body only. |
|||
27 Mar 2010, 21:53 |
|
Tomasz Grysztar 27 Mar 2010, 22:18
LocoDelAssembly wrote: baldr, sorry I don't have my brain turned on today, should I move this to compiler internals and flag it as a bug? |
|||
27 Mar 2010, 22:18 |
|
baldr 27 Mar 2010, 22:43
LocoDelAssembly,
If assembler don't know from where the source line came, how do it guess the exact error location so luckily? You can get the same error with any macro facility: macro / struc / irp / irps / match / rept. That error is not related to them directly: it's open_binary_file bug. By the way, this mod applies the same behavior change to format PE … on 'filename', section … resource from 'filename' and data resource from 'filename' directives. __________ Tomasz Grysztar, Was I lucky with my guess about [eax+12]? |
|||
27 Mar 2010, 22:43 |
|
Tomasz Grysztar 27 Mar 2010, 23:05
baldr wrote: Tomasz Grysztar, Yes, that was a very good guess. BTW, you can find some information about this structure in FASM.ASH file in fasm DLL package. |
|||
27 Mar 2010, 23:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.