flat assembler
Message board for the users of flat assembler.

Index > Main > Anyway to get time in FASM. (Nope! It's the preprocessor!)

Author
Thread Post new topic Reply to topic
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Yeah, so is there any way I can tell FASM to put the current time and date in my data section automatically?
Although it isn't of much use, but it does help when you want to tell the user like:
Code:
<PROGRAM NAME> Compiled on XX:XX:XX, XX/XX/XXXX    

Like,
Code:
db %%SYSTEM_TIME
db %%SYSTEM_DATE
    

Which will put the system time value and system date value as null-terminated strings in those places.

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 15 Mar 2014, 16:01
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
%t constant in FASM is always equal to the current time. One example of use: version.inc
Post 15 Mar 2014, 17:33
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
Actually %t is a variable. It can change each time your source reads it and on each pass.
Post 15 Mar 2014, 20:25
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
revolution, yes actually.
Post 16 Mar 2014, 06:40
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Is it string/bcd/integer Razz?
Post 16 Mar 2014, 07:24
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
It is an integer number - UNIX time format.
Post 16 Mar 2014, 07:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
JohnFound wrote:
version.inc
JohnFound: Every link on that page points to the same page that says:
Access by spiders and robots is forbidden
You might want to fix that.
Post 16 Mar 2014, 10:35
View user's profile Send private message Visit poster's website Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
@JohnFound: Thanks
@rev What? Works fine for me. This mean..s.. Th....a..t WE HAVE FINALLY FOUND WHO REVOLUTION IS! A BOT!
Post 16 Mar 2014, 11:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Fossil's antibot protection discussion continues here.
Post 16 Mar 2014, 19:25
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
There is not an easy way to do it?

I wanted to be able to choose the format as well, like the "date" program allows. It would require the time to be the same whenever it is found on the source.

If FASM does not provide an easy way to do it, then I will have to make a program (or edit FASM source, highly unlikely) to replace the constant "%TIME={date format}" with the "date +<format>" output. D:

If you know of an easier/smarter way, please let me know!

I apologize for any inconveniences, if any.

EDIT:
I found out it can be done with built in Linux/GNU commands. :D

EDIT2:
0.Backup all affected sources to <source>.bak.
1.Replace all occurrences of %TIME% with "date +<format>"
2.Try to compile
3.Restore original backup.

Bash script:
Code:
#!/bin/bash
set -e

t=$(date +'%Y\/%m\/%d - %H\:%M\:%S %Z');
for file in ./*.asm;
do cp -p $file $file'.bak';
sed -i "s/%TIME%/$t/g" $file;
done

make

for file in ./*.asm.bak;
do mv $file ${file%.bak};
done
    

It works! I'll be incorporating this in my "makefiles". If you have a better idea, please let me know.


Last edited by HaHaAnonymous on 20 Mar 2015, 07:11; edited 4 times in total
Post 18 Mar 2015, 15:56
View user's profile Send private message Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
sid123 wrote:
@JohnFound: Thanks
@rev What? Works fine for me. This mean..s.. Th....a..t WE HAVE FINALLY FOUND WHO REVOLUTION IS! A BOT!

maybe revolution is a spider


Last edited by gens on 19 Mar 2015, 15:21; edited 1 time in total
Post 18 Mar 2015, 19:09
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
@HaHaAnonymous, did you read the source from the second point in this thread? %T is just a number - the time/date in unix format. It can be converted in whatever format you need by some macros and FASM equations. (Usually the needed format is some kind of string, but there is no any limit)

Or I didn't understood you correctly? Please, provide some example then.
Post 18 Mar 2015, 19:15
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
Quote:

@HaHaAnonymous, did you read the source from the second point in this thread? %T is just a number - the time/date in unix format. It can be converted in whatever format you need by some macros and FASM equations.

I do not know how to write macros (not interested in learning it as well). D:

If you can provide one that could handle all possible formats of date... Please, then do it. :D

Otherwise, I will be using the good and old backup/search/replace/compile/restore alternative I described in my previous post.

Again, I apologize for any inconvenience (if any).

Thank you!
Post 18 Mar 2015, 19:45
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
HaHaAnonymous wrote:
I do not know how to write macros (not interested in learning it as well). D:


But you can write bash scripts and was interested to learn it... One syntax more, one less - it is not a big difference. Maybe you should try to learn FASM macros as well. It is very useful for FASM programming. I guarantee that. Smile

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 18 Mar 2015, 20:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
Quote:

But you can write bash scripts and was interested to learn it...

Not really. I just know the very basic things because it is really useful for automating simple tasks.

Quote:

Maybe you should try to learn FASM macros as well. It is very useful for FASM programming. I guarantee that.

Opinion observed. Perhaps one day... Not sure.

And another discouraging factor is that there is no way to know what is the current "Time Zone Abbreviation" from %T. D:

Not sure. Thank you!
Post 18 Mar 2015, 22:46
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
If you search this board there are already a few macros posted to do time computation and conversions.

The timezone for %t is dependant upon the function make_timestamp in SYSTEM.INC. For Win32 console it is UTC. For other versions (DOS?) it might be local time.
Post 18 Mar 2015, 23:12
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
Quote:

If you search this board...

This board search function is pretty useless. Because no matter how descriptive you are it always return thousands of results.

Unless you know EXACTLY the thread's title. If yes then it should return as first result, together with thousands of other irrelevant posts and/or topics.

A good alternative is to use Google's: "site:<site> <expression>". And that is if you use Google, otherwise check your search engine's commands for more information.

But it is not completely useless... It is good to find Author's post. :D

I apologize for any inconvenience, if any. D:
Post 19 Mar 2015, 00:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
The search provided in this board does not look into the title at all. You can only search the post contents. It can make finding some things tricky. Using an external engine is usually preferred IME.
Post 19 Mar 2015, 00:19
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.