flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Lists of comma-separated items. |
Author |
|
decard 12 Jun 2005, 13:39
Thanks for the description - it helped me a lot.
I was trying to write a helper macros for importing functions from DLLs. You can specify just a name of a dll file (like kernel32 or user32), and macro will include INC file with equates, and list of import functions. Only files with needed equates would be included. Here are the macros: Code: macro use_dll [dll] { common __dll_list equ forward match any , __dll_list \{ __dll_list equ __dll_list,dll \} match , __dll_list \{ __dll_list equ dll \} include '%fasminc%\equates\'#`dll#'.inc' } macro __import_lib [lib] { forward local _label if ~ lib#.redundant dd RVA lib#.lookup,0,0,RVA _label,RVA lib#.address end if common dd 0,0,0,0,0 forward if ~ lib#.redundant _label db `lib#'.dll',0 end if forward include '%fasminc%\apia\'#`lib#'.inc' } macro .idata { common section '.idata' import data readable match list,__dll_list \{ __import_lib list \} } Sample program with my macro should look like this: Code: format PE GUI include '%fasminc%\win32a.inc' include 'imports.inc' use_dll kernel32,user32 entry start section '.code' code readable executable start: invoke MessageBox, 0, _caption,_message,0 invoke ExitProcess,0 section '.data' data readable writeable _caption db 'Win32 assembly program',0 _message db 'Hello World!',0 .idata It is almost working... only there's a problem with equate files - when I try to compile source, FASM reaports "incomplete macro" error, pointing on first STRUCT definition in source file. What's wrong? |
|||
12 Jun 2005, 13:39 |
|
Tomasz Grysztar 12 Jun 2005, 13:59
Great thanks, you have found the bug in include processing that went unnoticed through all the earlier versions of fasm.
Please download the new release, it has it fixed. However your sample still won't work, since you are including the equates twice (and the "struct" cannot define the same structure twice, since it defines some global labels), but I guess you will fix this yourself. Last edited by Tomasz Grysztar on 12 Jun 2005, 14:11; edited 2 times in total |
|||
12 Jun 2005, 13:59 |
|
decard 12 Jun 2005, 14:07
Thanks
I forgot to write that win32a.inc has to be changed, I wasn't trying to include equates twice of course. |
|||
12 Jun 2005, 14:07 |
|
decard 12 Jun 2005, 14:54
Something is wrong again with my first macro, if I try to use relative path FASM can't find the file...
Code: macro use_dll [dll] { common __dll_list equ forward match any , __dll_list \{ __dll_list equ __dll_list,dll \} match , __dll_list \{ __dll_list equ dll \} include '..\equates\'#`dll#'.inc' ; <- here } |
|||
12 Jun 2005, 14:54 |
|
Tomasz Grysztar 12 Jun 2005, 15:05
The include happens when macro is invoked, that is when you are in the main file - so the path is relative to the path of main file. The similar problem I had to solve in WIN32AXP, you might take a look at it.
Probably the best is just to require the INCLUDE variable etc. |
|||
12 Jun 2005, 15:05 |
|
decard 12 Jun 2005, 15:17
I tried this:
Code: incdir fix '%myinc%' ; somewhere in the beginning of main file Code: macro use_dll [dll] { (...) include incdir#'\equates\'#`dll#'.inc' } Unfortunatelly FASM doesn't allow to use # operator anywhere but inside macroinstructions, which makes this solution not fully useful. |
|||
12 Jun 2005, 15:17 |
|
Tomasz Grysztar 12 Jun 2005, 15:30
Why not fully useful? You can just define the macros for including the files with given prefix.
And you can also do it with standard symbolic constant: Code: incdir equ '%myinc%' match dir,incdir { include dir#'\somefile.inc' } |
|||
12 Jun 2005, 15:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.