![]() |
|
|
#23 | |
|
Nov 2003
22×5×373 Posts |
Quote:
saved_edx_value = save_edx(); stime = get_time(); restored_edx_value(saved_edx_value); where save_edx and restore_edx_value are simple hand-coded _asm routines. But this is such a kludge! A better way is to rewrite get_time() in a way such that the compiler restores the edx register when it exits. I am unsure how to do that. Here is the current code: /************************************************************************/ /* */ /* Routine to access the clock. On Pentium prectime returns ticks */ /* */ /************************************************************************/ double get_time() { /* start of get_time */ return((double)prectime()); } /* end of get_time */ __int64 prectime(void) { __int64 t; unsigned int a,b; unsigned int *c = (unsigned int *)&t; _asm { _emit 0x0f; _emit 0x31; mov a,eax; mov b,edx; } c[0]=a; c[1]=b; return t; } |
|
|
|
|
|
|
#24 | |
|
Nov 2003
22·5·373 Posts |
Quote:
the edx register via: __int64 t; unsigned int a,b,tmp; unsigned int *c = (unsigned int *)&t; _asm { mov tmp, edx _emit 0x0f; _emit 0x31; mov a,eax; mov b,edx; mov edx,tmp } Yech! |
|
|
|
|
|
|
#25 |
|
Jun 2003
22·33·47 Posts |
Please see my earlier post -- It might not just be the edx register that you need to preserver. eax may also need to be preserved.
|
|
|
|
|
|
#26 | |
|
Jun 2003
22×33×47 Posts |
Quote:
|
|
|
|
|
|
|
#27 |
|
Jun 2003
22×33×47 Posts |
Can you post the code of your get_time function? Are you using opcodes using inline assembly or are you using __rdtsc() intrinsic (http://msdn.microsoft.com/en-us/library/twchhe95.aspx)?
Last fiddled with by axn on 2010-10-02 at 14:34 |
|
|
|
|
|
#28 | |
|
Nov 2003
22·5·373 Posts |
Quote:
|
|
|
|
|
|
|
#29 |
|
Nov 2003
22×5×373 Posts |
BTW, I did an explicit save/restore of eax, edx, and the code
now works fine. Last fiddled with by R.D. Silverman on 2010-10-02 at 16:08 |
|
|
|
|
|
#30 | |
|
Jun 2003
22·33·47 Posts |
Quote:
Code:
double get_time()
{ /* start of get_time */
return((double)__rdtsc());
} /* end of get_time */
|
|
|
|
|
|
|
#31 | |
|
Nov 2003
22×5×373 Posts |
Quote:
BTW, when I first wrote this code, the intrinsic did not exist...... |
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| mprime 28.10 compiler warning | Explorer09 | Software | 1 | 2017-01-23 02:50 |
| GCC/compiler warnings | Dubslow | Programming | 2 | 2016-02-27 06:55 |
| compiler/assembler optimizations possible? | ixfd64 | Software | 7 | 2011-02-25 20:05 |
| Linux32 -> Windows64 C compiler? | geoff | Programming | 3 | 2007-09-26 03:09 |
| /. Video processor compiler | tha | Hardware | 17 | 2005-10-12 08:10 |