[http://bbs.kldp.org/viewtopic.php?t=48025] {{{~cpp // 인라인 어셈 사용. fprep dd 59c00000h fadd [fprep] fsub [fprep] }}} {{{~cpp // C언어 함수 #ifdef __BIGENDIAN__ # define FTOI_LONG reserved, l #else # define FTOI_LONG l #endif #define USE_FTOI register union{ double r; struct { _integer4 FTOI_LONG; } l; } __ftoitmp; #define OP_FTOI(val)\ ( ( (__ftoitmp.r=(val)+((((65536.*65536.*16.)+(65536.*.5))*65536.)) ),\ __ftoitmp.l.l-0x80000000L ) ) }}} {{{~cpp // 테스트 #include #include #ifndef _WIN32 /* for linux/unix */ #include #include static void printf_localtime() { struct tm * ttt; struct timeval tv; gettimeofday(&tv, NULL); ttt = localtime(&tv); printf("%.4d-%.2d-%.2d %.2d:%.2d:%.2d.%.3d", ttt->tm_year, ttt->tm_mon, ttt->tm_mday, ttt->tm_hour, ttt->tm_min, ttt->tm_sec, tv.tv_usec/1000); } static unsigned int get_clock() { struct timeval tv; unsigned int t; gettimeofday(&tv, NULL); t = ((tv.tv_sec % 1000000) * 1000) + (tv.tv_usec / 1000); return t; } #else /* for windows */ #define get_clock clock #endif #ifdef __BIGENDIAN__ # define FTOI_LONG reserved, l #else # define FTOI_LONG l #endif #define USE_FTOI union{ double r; struct { long FTOI_LONG; } l; } __ftoitmp; #define OP_FTOI(val) \ ( ( (__ftoitmp.r=(val)+((((65536.*65536.*16.)+(65536.*.5))*65536.)) ), \ __ftoitmp.l.l-0x80000000L ) ) #define USE_FTOI2 union{ double r; struct { long FTOI_LONG; } l; } __ftoitmp; #define LOOPCNT1 10 #define LOOPCNT2 10000000 void conv1(double *dv, long *lv) { *lv = *dv; } void test1() { double dval = 123456789.12345678; long lval = 0; long total = 0; long start = 0, finish = 0; long avg = 0; long i=0, j=0; start = get_clock(); for(j=0; j