flat assembler
Message board for the users of flat assembler.
Index
> Main > Keep passed values after a cpuid call, dll procedure |
Author |
|
revolution 28 Apr 2020, 22:09
Remove the comma after rcx.
Code: proc ... uses rcx rdx |
|||
28 Apr 2020, 22:09 |
|
fpissarra 29 Apr 2020, 14:24
If you want to "measure the latency", you should follow Intel's recomendations. For example, they recomend to serialize the processor BEFORE trying to read TSC. You could use MFENCE before the serialization:
Code: push rbx ; MS ABI demands RBX, RSI and RDI to be preserved. push rsi push rdi mfence ; memory sync. xor eax,eax ; serialize processor. cpuid rdtsc ; store EDX:EAX somewhere... (probably 1 additional cycle). mov esi,eax mov edi,edx ... ... instructions to measure here... (RSI and RDI must be preserved!). ... ; OBS: You should reserialize the processor again here. to avoid ; reordering effects. xor eax,eax ; 20+ cycles, maybe? cpuid rdtsc ; subtract EDX:EAX from previously obtained EDX:EAX. sub eax,esi sbb edx,edi shl rdx,32 or rax,rdx ; OBS: You could subtract the additional cycles from RAX here. ; sub rax,21 ; 21 cyvles, maybe? ; jns .not_negative ; xor rax,rax ; clamp to zero. ; .not_negative: pop rdi pop rsi pop rbx ret But be aware that using TSC to measure latency isn't a precise method... |
|||
29 Apr 2020, 14:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.