flat assembler
Message board for the users of flat assembler.

Index > Main > How to generate incremented build version

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Hi guys
Is it possible to save build increments using fasm?
for example, initial build # = 0000. i run fasm to compile source code, and some variable somewhere in source increments. when i run fasm to compile source again, build increments one more time and so on, so with every compilation value of variable 'build' changes.
thanks in advance.
Post 26 Mar 2010, 23:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17639
Location: In your JS exploiting you and your system
revolution
You can use the %t variable to get a unique value at compile time. That way you can distinguish between builds and you can even know the time that it was built.
Post 27 Mar 2010, 01:14
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
zhak,
Code:
BUILD equ 1
format binary as "fasm"
file "self_inc.fasm"
load build byte from 10
store byte build+1 at 10    
This file (self_inc.fasm) increments BUILD symbolic constant value each time it is compiled (FASMW won't catch that, use FASM).
find "BUILD equ" <self_inc.fasm >build.finc (or grep) command can be used to extract equ directive (to be included in your source).

Alternatively, you can use awk to modify your source before compilation (and commit changes if it was successful).

You can parse previously compiled PE and use its build+1 (from VERSIONINFO resource, for example) too.
Post 27 Mar 2010, 01:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17639
Location: In your JS exploiting you and your system
revolution
baldr: fasm does not support extensions longer than 3 characters.
Post 27 Mar 2010, 01:24
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
revolution,

Are you sure? Win32 command line version compile this OK (I've even checked ".flat assembler" extension).
Post 27 Mar 2010, 01:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17639
Location: In your JS exploiting you and your system
revolution
I keep getting an error when I try it. I will look into what is happening.
Post 27 Mar 2010, 01:49
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: 17639
Location: In your JS exploiting you and your system
revolution
Oh, I had a read only file with the same name. Yeah you are right, it works fine as long as the file can be written.

BTW: I wonder what happens on a DOS system? Does the OS truncate everything to 3 character extensions?
Post 27 Mar 2010, 01:58
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Although it compiles, BUILD won't increment when it reaches "\", I'm also not sure what values after 9 will be - I still like the idea, might have a go later Cool
Post 27 Mar 2010, 10:04
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
cod3b453,

I didn't say that it is reliable/complete solution (insert empty line after equ and it will compile fine until \xFF). It is just a quick'n'dirty implementation of an idea.
Post 27 Mar 2010, 13:38
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
There was something strange at http://board.flatassembler.net/topic.php?t=5204
Add a little PE parsing to it and it would work. Maybe.
Post 27 Mar 2010, 20:22
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
SFeLi,

Unfortunately, that approach will work only if ver macro is invoked at fixed RVA (thus you can't move the invocation around the source after first build is built Wink). PE parsing and VERSIONINFO resource seems more reliable.
Post 27 Mar 2010, 21:18
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
OK, taking baldr's idea I got this:

build.ash
Code:
BUILD equ 00000000000000000000000000000001b    

build.asm
Code:
        format binary as "ash"
        file "build.ash"

        b = 0

        rept 32 i:0
         {
                load bb byte from (10+i)
                b = (b shl 1) or ((bb - '0') and 0x00000001)
         }

        b = b + 1

        rept 32 i:0
         {
                if b and (1 shl (31 - i))
                        store byte '1' at (10+i)
                else
                        store byte '0' at (10+i)
                end if
         }    

test.asm
Code:
        include 'build.ash'

        dd BUILD    


To increment BUILD you compile build.asm which overwrites build.ash and then include build.ash into the files where you want BUILD and compile them. This allows you to have a multi-platform build file too e.g.

Code:
; build.bat (chmod 07xx for UNIX) with fasm(.exe) in PATH
fasm build.asm
fasm test.asm    
Post 28 Mar 2010, 15:55
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
whoaaa!! this is very very very great!!! thanks a lot, cod3b453 and baldr!
Post 28 Mar 2010, 16:34
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
revolution wrote:
You can use the %t variable to get a unique value at compile time...
and that is the method.
Other macro-toy-methods should not be trusted. for the sake of completeness,
http://board.flatassembler.net/topic.php?t=9458
(it improves cability to "commend" this phpBB board search button) Razz

Cheers, Very Happy
hopcode

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 28 Mar 2010, 16:45
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
hopcode, the solution discussed in topic 9458 is for PE files. I don't need PE. I build flat binaries.
Post 28 Mar 2010, 17:33
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
Brilliant!!
Post 28 Mar 2010, 17:51
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
hopcode,

%t is the only consistent method of versioning.

__________
cod3b453,

Where is the hash/bang combo? Wink
Post 28 Mar 2010, 17:54
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
revolution wrote:
Oh, I had a read only file with the same name. Yeah you are right, it works fine as long as the file can be written.

BTW: I wonder what happens on a DOS system? Does the OS truncate everything to 3 character extensions?


FASM for DOS supports LFNs if available. Otherwise it should truncate to 8.3.
Post 28 Mar 2010, 18:09
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
baldr wrote:
hopcode,
%t is the only consistent method of versioning.

Yes, Very Happy Laughing i said it because the too much verbal and too much brief 2nd post was perhaps marked as unbelievable and consequently skipped Laughing

...but the blog doesnt evaluates to ETERNAL_CONST if i miss to quote the source:
zhak wrote:
I don't need PE.I build flat binaries.

Code:
Ohh mein Gott, you need a flattery bin !!!! How would you do that !?!
    

Good that you asked about it!
zhak again wrote:
Hi guys
Is it possible to save build increments using fasm?
for example, initial build # = 0000. i run fasm to compile source code, and some variable somewhere in source increments. when i run fasm to compile source again, build increments one more time and so on, so with every compilation value of variable 'build' changes.
thanks in advance.

If you hadnt asked about it, how would have been the mortal being and the black fly aware of the flat apartment you asked?

Also, confirmed: under a general written english improvements,
and the board will remain over centuries the same version,
lack of commuication follows...in blocks...blog..bl..a,bl..a
VVV Cool Cool peace, unity,love and having fun Cool CoolVVV

hopcode

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 28 Mar 2010, 22:10
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
zhak wrote:
whoaaa!! this is very very very great!!! thanks a lot, cod3b453 and baldr!
No problem - I had tried to do this a long time ago but never thought to try what baldr suggested, so I can only thank you asking and baldr for his idea Cool

baldr wrote:
Where is the hash/bang combo?

It breaks Windows compatibility, was just to show that you could use the same build and source files on both platforms - which for me is very useful because I develop on both.
Post 29 Mar 2010, 13:05
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.