flat assembler
Message board for the users of flat assembler.
Index
> Windows > Can you halp me to write timer into DLL |
Author |
|
revolution 10 Dec 2017, 15:46
You can use Sleep to delay execution.
Code: invoke Sleep,1000 ;wait 1 second (1000 milliseconds) |
|||
10 Dec 2017, 15:46 |
|
DarkLordTed 10 Dec 2017, 17:09
Thank you!
|
|||
10 Dec 2017, 17:09 |
|
DimonSoft 11 Dec 2017, 11:57
DarkLordTed
I guess, it’s worth noting that you’ve probably divided your problem into two parts: easy and strange. Asking for a blocking delay (synchronous) is really strange and, generally, smells like bad design. What problem are you REALLY trying to solve? |
|||
11 Dec 2017, 11:57 |
|
Furs 11 Dec 2017, 12:58
Maybe look at SetTimer?
|
|||
11 Dec 2017, 12:58 |
|
donn 12 Dec 2017, 17:57
If you're looking for something more high-resolution, I've been using QueryPerformanceCounter (https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx), which is encouraged over rdtsc/p. It's trickier to use than sleep/setTimer, but the overhead is 10s-100s of cycles with fine-grained results.
I've written some wrappers for them, but haven't spent much time on it. One version seems to work and notifies when x ms pass, or that x ms pass, the other function returns the same in microseconds. They're not tested enough, but seemed to time the correct amount of time elapsed so far. They use qpc mainly like this: Code: sub rsp, 8*4 mov rcx, [newTime.time.frequency] call [QueryPerformanceFrequency] add rsp, 8*4 Save start time: Code: mov rbx, [startTime.time] mov rdx, rbx add rdx, Time.duration ; Get Time.duration address mov r11, [rdx] mov qword [r11], 0 ; Initialize as 0 sub rsp, 8*4 add rbx, Time.start mov rcx, [rbx] call [QueryPerformanceCounter] add rsp, 8*4 query the delta time, divide by freq: Code: sub rsp, 8*4 mov rbx, [deltaTime.time] add rbx, Time.duration mov rcx, [rbx] call [QueryPerformanceCounter] add rsp, 8*4 using a struc with ptrs: Code: struc Time{ .duration dq 0 ;Address .frequency dq 0 ;Address .start dq 0 ;Address } I can post any 64-bit functions/the Time.inc file I'm using, but would need to test it a bit more and provide an integer result version. I'm currently outputting as single precision. |
|||
12 Dec 2017, 17:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.