diff options
author | yves <steve.harrison@gmx.net> | 2011-05-25 09:52:21 +0200 |
---|---|---|
committer | yves <steve.harrison@gmx.net> | 2011-05-25 09:52:21 +0200 |
commit | 4dd1918a8ca6b48cc8cf13716e15b87306fbdf32 (patch) | |
tree | 06fab97dab53e752c9e061f79d35c2c100be018a /inlineasm.h | |
parent | ef176e8f2d80fbdebb3b6e00005dd873fc2c4233 (diff) | |
download | manycore-4dd1918a8ca6b48cc8cf13716e15b87306fbdf32.tar.gz manycore-4dd1918a8ca6b48cc8cf13716e15b87306fbdf32.tar.bz2 manycore-4dd1918a8ca6b48cc8cf13716e15b87306fbdf32.zip |
yeahyves.asm
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) ); } |