diff options
Diffstat (limited to 'inlineasm.h')
-rw-r--r-- | inlineasm.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/inlineasm.h b/inlineasm.h index 218c532..6e33660 100644 --- a/inlineasm.h +++ b/inlineasm.h @@ -63,21 +63,28 @@ static uint64_t memmeasure(char* memory, uint64_t offset) // rdtsc to save instrucions. it is not significantly faster than the // accurate one but it has fewer instrucions and by that is less likely // to be delayed by the scheduler -// averages at about 72.5 ticks with an offset of 1 -static uint64_t optmemmeasure(char* memory, uint64_t offset) +static uint64_t optmemmeasure(char* memoryFirst, char* memorySecond) { - asm( + asm volatile ( + // load other value + "mov (%%rbx), %%rax ;" + + // start clock measure "rdtsc ;" "mov %%eax, %%edi ;" - - // here be magic dragons and memory access (read segfaults) ahead - // TODO: evaluate if more cmp types (like w and l) do make sense - "cmpb $0x23, (%%rbx) ;" - "cmpb $0x42, (%%rbx,%%rcx) ;" - + + // load second value + "mov (%%rcx), %%rdx ;" + + // stop clock measure "rdtsc ;" "sub %%edi, %%eax ;" - : : "b" (memory), "c" (offset) + + // do shit + "xor (%%rax,%%rdx), %%rbx ;" + "mov %%rbx, (%%rcx) ;" + + : : "b" (memoryFirst), "c" (memorySecond) ); } |