Would be nice to use proper inline functions. Anyway, here is your macro version.
Up vote 1 down vote favorite 1 share g+ share fb share tw.
This is the original code: #define CPU_PREFETCH(cache_line) \ { int* address = (int*) (cache_line); \ _asm mov edx, address \ _asm prefetcht0edx \ } #define CPU_GET_CYCLES(low) \ { \ _asm rdtsc \ _asm mov dword ptr low, eax \ } #define CPU_SYNC \ { \ _asm mov eax, 0 \ _asm cpuid \ } #define CPU_CACHE_FLUSH(cache_line) \ { int* address = (int*) (cache_line); \ _asm mov edx, address \ _asm clflushedx \ _asm mfence \ } Thanks to Jester, I now have this: #define CPU_PREFETCH(cache_line) \ { \ __asm__ __volatile__ ("prefetcht0 %0" : : "m" (*(int*)cache_line)); \ } #define CPU_GET_CYCLES(low) \ { \ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "%edx"); \ } #define CPU_SYNC \ { \ __asm__ __volatile__ ("cpuid" : : : "%eax", "%ebx", "%ecx", "%edx"); \ } #define CPU_CACHE_FLUSH(cache_line) \ { \ __asm__ ("clflush %0; mfence" : : "m" (*(int*)cache_line)); \ } Evidently, gcc doesn't like volatile with clflush. Thanks everyone. I am trying to compile Slicing-By-8 with gcc as a dll so I can use it in my VB6 app.
How is that for irony? 0_o c gcc assembly inline gas link|improve this question edited Dec 19 '10 at 19:13 asked Dec 19 '10 at 8:27selyb83.
Would be nice to use proper inline functions. Anyway, here is your macro version: #define CPU_PREFETCH(cache_line) \ { \ __asm__ __volatile__ ("prefetcht0 %0" : : "m" (*(int*)cache_line)); \ } #define CPU_GET_CYCLES(low) \ { \ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "%edx"); \ } #define CPU_SYNC \ { \ __asm__ __volatile__ ("cpuid" : : : "%eax", "%ebx", "%ecx", "%edx"); \ } #define CPU_CACHE_FLUSH(cache_line) \ { \ __asm__ __volatile__ ("clflush %0; mfence" : : "m" (*(int*)cache_line)); \ }.
Man, that looks beautiful and looks as though you know exactly what you're doing :) Anyway, I get this error now: Error: operand size mismatch for `clflush' – selyb Dec 19 '10 at 17:22 I tried to click that this post was useful but I don't have enough reputation – selyb Dec 19 '10 at 19:14.
You can do it like this: add this line before any other assembly lines: asm(". Intel_syntax noprefix\n"); Then run GCC like this: gcc -o my_output_file -masm=intel my_src_file. C Thanks to stingduk at BiW Reversing.
This gives me a different error as shown in first post. – selyb Dec 19 '10 at 8:54 He forgot to add the backslash. – Hans Passant Dec 19 '10 at 17:01 Updated first post again – selyb Dec 19 '10 at 17:08.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.