Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <malloc.h>
- void main(int argc,char *argv[])
- {
- long long *mesure=memalign(4096,8*0xf);
- if(mesure == NULL)
- {
- perror("alloc\n");
- return;
- }
- asm volatile("movq %0,%%r14\n\t"::"a"(&err));
- asm volatile("movq %0,%%r15"::"a"(mesure));
- asm volatile("xor %rcx,%rcx\n\t");
- asm volatile("jmp set0\n\t");
- asm volatile(
- ".align 4096\n\t"//align to L1 cache : = #set * lineSize
- "set0: \n\t"
- "mov $30,%rdi\n\t"
- "push %rcx\n\t"
- "call sleep\n\t"
- "pop %rcx\n\t"
- /*".rept 14\n\t"
- "nop\n\t"
- ".endr\n\t"*/
- "mfence\n\t" //line 0 in RAM => set 0
- "rdtsc\n\t"
- "mov %rax,%r11\n\t"//low[i]
- "mov %rdx,%r12\n\t"//high[i]
- "jmp set35\n\t"
- ".rept 34\n\t"//34 si haut, 48 sinon
- "nop\n\t"
- ".endr\n\t"
- ".rept 411712\n\t"//6272\n\t"//2176,64(j-i-1)
- "nop\n\t"
- ".endr\n\t"
- "set35 : \n\t" //line 65 in RAM => set 65 % 64 = 1
- "mfence\n\t" //set 1
- "rdtsc\n\t"
- "shl $32,%rdx\n\t"//high[i+1]<<32
- "shl $32,%r12\n\t"//high[i]<<32
- "or %r12,%r11\n\t"//start=(high[i]<<32) | low[i]
- "or %rax,%rdx\n\t"//end=(high[i+1]<<32) |low[i+1]
- "sub %r11,%rdx\n\t"//end-start
- "mov %rdx,(%r15)\n\t"
- "add $8,%r15\n\t"
- /*"mov $30,%rdi\n\t"
- "push %rcx\n\t"
- "call sleep\n\t"
- "pop %rcx\n\t"*/
- ".rept 14\n\t"// some nops to replace the previous commented code (it's size is 14Bytes)
- "nop\n\t"
- ".endr\n\t"
- "inc %rcx\n\t"
- "cmp $0x5,%rcx\n\t"
- "jne set0\n\t"
- "END:\n\t"
- );
- int i=0;
- unsigned int count = 0;
- for(i=0;i<0xf;i++)
- {
- printf("\n%llx",mesure[i]);
- if(mesure[i]>0x100)
- count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment