flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > -D switch again

Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i found out i changed stance on the "-D" (define symbol) and "-i" (additional include path) problem, after trying to code in conventional way - create multiple object files.

For usual way of using FASM, where you produce executable directly, you really need just to change your thinking, and docs say. But with conventional programming, where you divide your code among many .obj files, this is a must-have. Without this, FASM really can't be effectively used for such programming IMO.

Note that the second way, even though less confortable, is little bit more powerful, because it allows mixing languages (use C libraries, create asm libraries for C projects, etc...).

Here is the real-world problem: In FASMLIB i have functions "text.write.b2hex", "text.write.w2hex", "text.write.d2hex", etc...
Then, i have functions "stdout.write.XXX", which are just wrappers to "text.write.XXX", they add one extra argument to stack.

FASMLIB can be used both by including it's source (typical FASM way), or by linking to .lib file.

For source, declaring such wrappers is enough:
Code:
irp x, b2hex, w2hex, d2hex...
{
  if used stdout.write.#x
    stdout.write.#x:
      ;add extra argument here
      call text.write.#x
  end if
}    
This way i don't have to type same code for each function.

But when i want to create .lib file, i need every such call wrapper in separate file. With -D switch, it would be enough to have single file, which would use caller-defined symbol, and assemble it multiple times.

Do you know of any other solution than -D switch for this?

PS: I believe this is same problem that arafael had some time ago, i just can't find it now
Post 03 Apr 2007, 22:01
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
simply put: SSSO principe is not so nice when you need to output more than one destination file
Post 03 Apr 2007, 22:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
"but you can just use environment variables".

I have to agree, though -D is immensively useful. Producing debug/release builds, and a number of other things. The SSSO principle means you have to edit files or kludge around to achieve the same things as -D could do for you...
Post 03 Apr 2007, 22:17
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
vid wrote:
simply put: SSSO principe is not so nice when you need to output more than one destination file

Then you should need more than one source file, as the output is unequivocally determined by a single one.
You may not like it, but it has its rules. "Dura lex, sed lex", as they say. Wink
Post 04 Apr 2007, 07:24
View user's profile Send private message Visit poster's website Reply with quote
kandamun



Joined: 20 Jul 2005
Posts: 25
kandamun
Hi vid,
I would do it like this:

include CONFIG.INC in you sources
then in your build script do the equivalence of:
Code:
echo PARAM = 1 > CONFIG.INC
fasm sources.asm ...
    
Post 11 Apr 2007, 08:57
View user's profile Send private message ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
kandamun: that's what's called a HACK Smile
Post 11 Apr 2007, 09:02
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.