/* * main.c * * Created on: 23.04.2010 * Author: sven */ #include #include #include #include #include #define HI(x) (x >> 16) #define LO(x) (x & 0x0000FFFF) void mulc(uint32_t *u, uint32_t *v, uint32_t a, uint32_t b) { uint32_t t; t = LO(a) * LO(b); *v = LO(t); t = HI(t) + HI(a) * LO(b); *u = HI(t); t = LO(t) + LO(a) * HI(b); *v |= LO(t) << 16; *u += HI(t) + HI(a) * HI(b); } void mula(uint32_t *u, uint32_t *v, uint32_t a, uint32_t b) { asm ( "mov %2,%%eax\n" "mul %3\n" "mov %%edx, %0\n" "mov %%eax, %1" :"=r"(*u),"=r"(*v) :"r"(a),"r"(b) ); } void initRandomizer() { srand(time(NULL)); } uint32_t getRandomUint32() { uint32_t res = rand(); if(res % 2) { return (res | 1<<31); } return res; } int main(int argc, char* argv[]) { initRandomizer(); uint32_t a = getRandomUint32(); uint32_t b = getRandomUint32(); uint32_t u,v; uint32_t counter; uint32_t outerCnt; const uint32_t NUM_INNER_LOOPS = 1000000; const uint32_t NUM_OUTER_LOOPS = 1000; struct timeval startc; struct timeval endc; struct timeval starta; struct timeval enda; long diffCsum = 0,diffAsum = 0; for(outerCnt=0;outerCnt