flat assembler
Message board for the users of flat assembler.

Index > Main > Feature request - time directive

Author
Thread Post new topic Reply to topic
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
I think it would be great if the compiler had a time directive that returned a structure of the current time. For example, if I wanted each program on compilation to have its own unique key value without having to do it at runtime.

Like so:

Code:
ENC_KEY:
   STATIC_KEY_0  DB  time.date
   STATIC_KEY_1  DB  time.day
   STATIC_KEY_3  DW time.year

SOME_4BYTE_CHUNKED_DATA dd   $1234, $4567, $89AB, $CDEF,$0000
start:
       lea     esi,  [SOME_4BYTE_CHUNKED_DATA]
       mov   eax, DWORD[ENC_KEY]    ; 

       XOR   DWORD[ESI], eax
       INC    ESI
       ..etc

    
Post 02 May 2012, 02:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
Use %t
Code:
current_time = %t    
Post 02 May 2012, 03:30
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
What is the format of %t? Seconds since January 1, 1970, 12:00 pm GMT? in 32 bits or more?
Post 02 May 2012, 04:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
There are already plenty of threads here relating to time conversions.

This is a good one to start with: http://board.flatassembler.net/topic.php?t=1139

smiddy: Here is one you already participated in so you should already know: http://board.flatassembler.net/topic.php?t=14096

typedef: You already knew about %t: http://board.flatassembler.net/topic.php?t=12996

Read the entire thread(s). Don't simply read the first post. Various bugs were fixed later etc.
Post 02 May 2012, 05:36
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
revolution wrote:
Use %t
Code:
current_time = %t    


How can I use the display macro to display %t as a string.
Post 02 May 2012, 05:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
typedef wrote:
How can I use the display macro to display %t as a string.
Read my post above
Post 02 May 2012, 05:43
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Damn, I think he(revolution) keeps track of posts we all make. I better start watching my mouth here...err....typing. Very Happy

BTW: Thanks
Post 02 May 2012, 05:54
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
I reread through those posts and it still doesn't answer my questions specifically. Since I never used %t because it can not pull file information, particularly date and time, I have not used it. I see it is in seconds, but from what epoch, and is it specifically 32 bits or can/could it be 64 bits?

Is this correct:
baldr wrote:
All timestamps are UTC (GMT±0) Wink
Post 02 May 2012, 10:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
When all else fails, read the source:
SOURCE\LINUX\SYSTEM.INC wrote:
Code:
make_timestamp:
       mov     eax,13
      mov     ebx,timestamp
       int     0x80
        mov     eax,dword [timestamp]
       mov     edx,dword [timestamp+4]
     ret    
Post 02 May 2012, 10:41
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
It is the same as Unix time. It currently fits in 31 bits, it will occupy 32 bits no sooner than in 2038, and 33 after another 68 years, etc.

Numbers in fasm have no defined bit length, the language design treats them as if they were 2-adic numbers (infinite length).
Post 02 May 2012, 10:44
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Thanks for the clarification folks!
Post 02 May 2012, 11:49
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Does Linux (properly) support times before 1970??? ("touch -d 19130705 giddy" seems to work, surprisingly.)

DJGPP 2.04's time_t seems to be "unsigned int" (32-bits).
Lucid Puppy Linux 5.28's 32-bit headers say "long int" (32-bits).

And the relevant portion from the link posted above says this:

Quote:

The POSIX and Open Group Unix specifications include the ISO C standard library, which includes the time types and functions defined in the <time.h> header file. The ISO C standard states that time_t must be an arithmetic type, but does not mandate any specific type or encoding for it.


Though I assume that could?? change depending on which POSIX (2001? 2004? 2008) you support. And it seems that RFC1952 (Gzip) only supports unsigned (1970-present) anyways.

Fun fun fun. Razz
Post 02 May 2012, 21:10
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
Code:
.compiletime  dq %t
    


cool!!!! Smile

now i have a goal, do the gregorian conversions routines to convert from this %t to some time structure, and vice versa. in order to display dates, and handle the more friendly. Smile

and then, deal with the 29th february support difficulties.... Smile
Post 02 May 2012, 22:06
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
rugxulo wrote:
Does Linux (properly) support times before 1970??? ("touch -d 19130705 giddy" seems to work, surprisingly.)

DJGPP 2.04's time_t seems to be "unsigned int" (32-bits).
Lucid Puppy Linux 5.28's 32-bit headers say "long int" (32-bits).

And the relevant portion from the link posted above says this:

Quote:

The POSIX and Open Group Unix specifications include the ISO C standard library, which includes the time types and functions defined in the <time.h> header file. The ISO C standard states that time_t must be an arithmetic type, but does not mandate any specific type or encoding for it.


Though I assume that could?? change depending on which POSIX (2001? 2004? 2008) you support. And it seems that RFC1952 (Gzip) only supports unsigned (1970-present) anyways.

Fun fun fun. Razz

Great point, which I was so far removed from in "trying to point out" in only knowing the origin, since...dare I say, time is <cough> relative. Very Happy
Post 02 May 2012, 23:29
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.