flat assembler
Message board for the users of flat assembler.

Index > Linux > Get high resolution sys_time

Author
Thread Post new topic Reply to topic
rCX



Joined: 29 Jul 2007
Posts: 172
Location: Maryland, USA
rCX 12 Jul 2021, 02:11
I saw that the linux system time in seconds can be obtained using

Code:
mov  eax, 13
xor  ebx, ebx
int  80h ; return system time in seconds in eax
    



Is there a way to obtain the time at a higher resolution e.g milliseconds?
Post 12 Jul 2021, 02:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20483
Location: In your JS exploiting you and your system
revolution 12 Jul 2021, 07:08
There is GETTIME
Code:
SYS_CLOCK_GETTIME       = 265
CLOCK_MONOTONIC         = 1

struc timespec {
        .tv_sec         rd 1
        .tv_nsec        rd 1
}

time timespec

        mov     ecx,time
        mov     ebx,CLOCK_MONOTONIC
        mov     eax,SYS_CLOCK_GETTIME
        syscall ; or int 0x80    
Post 12 Jul 2021, 07:08
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 435
Location: Australia
redsock 12 Jul 2021, 20:45
This is also exposed via the vDSO for syscall-free gettimeofday operation, which provides microsecond resolution.
Code:
man 7 vdso    
for that and clock_gettime which can provide higher resolution still.

_________________
2 Ton Digital - https://2ton.com.au/
Post 12 Jul 2021, 20:45
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.