flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > [fasmg] Parametrized assembly

Author
Thread Post new topic Reply to topic
marste



Joined: 05 May 2015
Posts: 35
[fasmg] Parametrized assembly
I'm trying to produce 2 different binaries from a single compilation batch.

I would like to know if there is a way to call fasmg defining externally some symbol, e.g.

Code:
fasmg -define PAR=VAL1 file.asm file.out1
fasmg -define PAR=VAL2 file.asm file.out2

(with some conditional compilation inside file.asm depending on PAR value)

If not the solution can be to rename some include files between the two compilations, but I think it's not really elegant...
Post 15 Apr 2017, 08:21
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6356
Location: Kraków, Poland
There is no such option at the moment.
Post 15 Apr 2017, 09:02
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6356
Location: Kraków, Poland
The option I had in mind for fasmg would allow to prefix source with any line of text specified in command line. This way it would be possible not only to define symbols from command line, but for example include an additional file, like an instruction set:

Code:
fasmg -i DEBUG=1 source.asm output.bin
fasmg -i INCLUDE('x64.inc'test.asm test.bin

It then could be possible to assemble some of the sources made for fasm 1 with no modification, only by adding an option to include instruction set and output format macros.
Post 15 Apr 2017, 10:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6356
Location: Kraków, Poland
You gave me an impulse to finally implement it, I had it mostly figured out anyway. The syntax is exactly as I proposed above, and these samples should work correctly.

Since -I allows to execute any command or even a sequence of commands, it allows to do some interesting tricks. It is now possible to generate an output without any source file:

Code:
; in Windows:
fasmg nul -i "db 256 dup $" ascii.bin
; in Linux:
fasmg /dev/null -i "db 256 dup $" ascii.bin

Or even interpret some commands without handling any files at all:

Code:
; in Windows:
fasmg nul nul -i "display 74"
; in Linux:
fasmg /dev/null /dev/null -i "display 74"

With multiple -I switches it is possible to create and execute any sequence of commands:

Code:
; in Windows:
fasmg nul nul -i "x = 1 shl 500" -i "repeat 1, v:x" -i "display `v" -i "end repeat"
; in Linux:
fasmg /dev/null /dev/null -i "x = 1 shl 500" -i "repeat 1, v:x" -i "display `v" -i "end repeat"

Post 15 Apr 2017, 17:19
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 35
Great Tomas!!! Above any excpectations!!!

After your first reply I implemented the renaming file trick, but I'm happy to undo everything and start using this fantastic possibility!!! Very Happy

I think it will be useful for a lot of people and situations...

Thank you!!!
Post 15 Apr 2017, 17:38
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 473
Location: Belarus
this is indeed a very cool option
Post 15 Apr 2017, 20:13
View user's profile Send private message Reply with quote
jmg



Joined: 18 Sep 2016
Posts: 62
Re: [fasmg] Parametrized assembly

marste wrote:
...
If not the solution can be to rename some include files between the two compilations, but I think it's not really elegant...


I've usually done simply that, but this new feature allows both methods, and can be easier to maintain. Looks nice.
Post 17 Apr 2017, 06:02
View user's profile Send private message Reply with quote
mrvl



Joined: 22 Oct 2015
Posts: 1
Thank you so much for your work, Tomasz!

I have a small problem with this code:

Code:
fasmg nul test.bin -i "dd %t"


fasmg says:

Quote:
eval [1]:
dd t
Processed: dd t
Error: symbol 't' is undefined or out of scope.



Is the introduction of support expected for %t?
Post 23 Apr 2017, 09:07
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6356
Location: Kraków, Poland

mrvl wrote:
I have a small problem with this code:

Code:
fasmg nul test.bin -i "dd %t"


It seems that the "%" character is stripped by the batch interpreter if this is put into batch file. It worked for me when I put the double "%" there:

Code:
fasmg nul test.bin -i "dd %%t"

Post 23 Apr 2017, 10:27
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.