flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > FASM's -d cmdline option

Author
Thread Post new topic Reply to topic
Japheth



Joined: 26 Oct 2004
Posts: 151
Hello,

I wanted to use FASM's new -d option, but run into a problem.

The source (template.asm) is

Code:
;--- FASM template source to define an import (template.asm)

 format COFF
    
macro defext name
{
  extrn name
    public __imp__ # name
__imp__# name dd name
}

      section '.data' data
      defext ?IMP
    


and FASM is launched with

fasm -d ?IMP=_AllocConsole@0 template.asm

but the symbol ?IMP is not changed to "_AllocConsole@0" in the resulting .OBJ file, it is still "?IMP".

Is -d supposed to define numeric values only?
Post 21 Feb 2008, 05:18
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15912
Location: SDSS J140821.67+025733.2
I haven't tried it but I imagine that "-d ?IMP=anything" is the same as doing "define ?IMP" at the first line in the source?
Post 21 Feb 2008, 05:30
View user's profile Send private message Visit poster's website Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
revolution wrote:
I haven't tried it but I imagine that "-d ?IMP=anything" is the same as doing "define ?IMP" at the first line in the source?


Yes. Apparently it isn't really a problem with the -d option, it's more a problem with the '#' operator in macros, because the "extrn name" uses the externally defined name, but 'imp__#name' ignores it.
Post 21 Feb 2008, 05:38
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6906
Location: Kraków, Poland
See manual, section 2.3.7 for explanations.
Post 21 Feb 2008, 10:24
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6906
Location: Kraków, Poland
In other words, you just need to use "match" directive in order to concatenate the value of symbolic constant to some other value:
Code:
macro defext name
{
    extrn name
    match realname,name
    \{ public __imp__ \# realname
       __imp__# name dd realname \}
}    

You may find also these articles interesting, the are planned to become the part of Understanding fasm (which also may be helpful to explain how the # operator works).
Post 04 Mar 2008, 06:16
View user's profile Send private message Visit poster's website Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Tomasz Grysztar wrote:
In other words, you just need to use "match" directive in order to concatenate the value of symbolic constant to some other value:
Code:
macro defext name
{
    extrn name
    match realname,name
    \{ public __imp__ \# realname
       __imp__# name dd realname \}
}    



using match directive does the job, thanks!

btw, the availability of the -d option makes a -q option (to suppress the display of the "logo" and the "passes") useful now.
Post 04 Mar 2008, 11:06
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6906
Location: Kraków, Poland
Japheth wrote:
btw, the availability of the -d option makes a -q option (to suppress the display of the "logo" and the "passes") useful now.

No problem.
Post 04 Mar 2008, 11:07
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2292
Location: Usono (aka, USA)
[quote="Japheth"]
btw, the availability of the -d option makes a -q option (to suppress the display of the "logo" and the "passes") useful now.
[/quote]

How so?

(BTW, thanks to Tomasz for helping him.)
Post 04 Mar 2008, 14:31
View user's profile Send private message Visit poster's website Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Quote:
Quote:

btw, the availability of the -d option makes a -q option (to suppress the display of the "logo" and the "passes") useful now.


How so?


Because -q is the only option which you can get by mirroring -d.
Post 04 Mar 2008, 16:28
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-2018, Tomasz Grysztar.

Powered by rwasa.