flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] Parametrized assembly

Author
Thread Post new topic Reply to topic
marste



Joined: 05 May 2015
Posts: 44
marste 15 Apr 2017, 08:21
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



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Apr 2017, 09:02
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



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Apr 2017, 10:23
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



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Apr 2017, 17:19
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: 44
marste 15 Apr 2017, 17:38
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: 501
Location: Belarus
zhak 15 Apr 2017, 20:13
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
jmg 17 Apr 2017, 06:02
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
mrvl 23 Apr 2017, 09:07
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



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 23 Apr 2017, 10:27
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
marste



Joined: 05 May 2015
Posts: 44
marste 07 Sep 2017, 23:28
I've got a segmentation fault seems after using 16 times the "-i" options (in one single compile): there is such a limit?
Post 07 Sep 2017, 23:28
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 08 Sep 2017, 07:22
There are no limits, you must have found a bug. What is the command line that causes it? Does it happen consistently? Does it depend only on the command line and not source text?
Post 08 Sep 2017, 07:22
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 11 Sep 2017, 18:36
Following one example of this:

Code:
nome="1kRealChess81-F23-DEBUG"
../fasmg \
      -i 'ROMPLATFORM equ "ZX81"' \
      -i 'FLICKERFREE=0' \
      -i 'ALFABETA=1' \
      -i 'BEAUTY=1' \
      -i 'PLAYING equ "FLEXIBLE"' \
      -i 'FLEXIBLEMOVEBOOK=0' \
      -i 'MAXPLY=3' \
      -i 'QUIESCENCESEARCH=1' \
      -i 'MAXPLY_QUIESCENCESEARCH=4' \
      -i 'MOVESELECT equ "FIRST"' \
      -i 'INCREASINGPLY=0' \
      -i 'MOVEORDERING=1' \
      -i 'DEBUG=1' \
      -i 'DEBUGBLACKSTART=1' \
      -i 'MAXPLY_QUIESCENCESEARCH=0' \
      -i 'HUMANCOLOR=0' \
      -i 'ZX81COLOR=8' \
      sm1kzx8x.asm $nome.p > $nome.lst
    


And this is the result:

Code:
./build.sh: line 84: 13227 Segmentation fault      (core dumped) ../fasmg -i 'ROMPLATFORM equ "ZX81"' -i 'FLICKERFREE=0' -i 'ALFABETA=1' -i 'BEAUTY=1' -i 'PLAYING equ "FLEXIBLE"' -i 'FLEXIBLEMOVEBOOK=0' -i 'MAXPLY=3' -i 'QUIESCENCESEARCH=1' -i 'MAXPLY_QUIESCENCESEARCH=4' -i 'MOVESELECT equ "FIRST"' -i 'INCREASINGPLY=0' -i 'MOVEORDERING=1' -i 'DEBUG=1' -i 'DEBUGBLACKSTART=1' -i 'MAXPLY_QUIESCENCESEARCH=0' -i 'HUMANCOLOR=0' -i 'ZX81COLOR=8' sm1kzx8x.asm $nome.p > $nome.lst
    


If I remove the last three -i it works!

PS: flat assembler version g.hwx32

PS2: Ubuntu 16.04 (64 bit)
Post 11 Sep 2017, 18:36
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 11 Sep 2017, 20:51
There was a bug in the string storage, only uncovered when the total length of text generated by -I parameters was more than 256.
Please try the "hx7tl" version.
Post 11 Sep 2017, 20:51
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 12 Sep 2017, 21:44
Tomasz Grysztar wrote:
There was a bug in the string storage, only uncovered when the total length of text generated by -I parameters was more than 256.
Please try the "hx7tl" version.


It works now! Smile
Post 12 Sep 2017, 21:44
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.