#include <stdio.h> int times5(int n) { asm ("leal (%1,%1,4), %0" : "=r" (n) : "0" (n) ); return n; } void test_times5() { int n = 2; printf("%d\n", times5(n)); } #define rep_movsl(src, dest, numwords) \ __asm__ __volatile( \ "cld\n\t" \ "rep movsl" \ : \ : "S" (src), "D" (dest), "c" (numwords)) void test_rep_movsl() { int src[] = {100, 200, 300}; int dest[3]; rep_movsl(src, dest, 3); int i; for (i = 0; i < 3; i++) printf("dest[%d]: %d\n", i, dest[i]); } #define RDTSC(ll) ({ \ __asm__ __volatile__ ( \ ".byte 0x0f; .byte 0x31" \ : "=A" (ll) ); }) void test_RDTSC() { unsigned long long ll = 0; RDTSC(ll); printf("time-stamp counter: %#llX", ll); } int main(int argc, const char *argv[]) { test_times5(); test_rep_movsl(); test_RDTSC(); return 0; }