我的C代码如下。它调用汇编函数。
clock_t t = clock();
asmfunction(input);
t = clock() - t;
printf("%.5f\n", ((float)t)/CLOCKS_PER_SEC);
我使用组件x86-32+SSE
asmfunction
.
我不明白为什么第二个
clock()
调用返回nan。
我的汇编代码是一个进行过程调用的循环。我注意到,如果它迭代超过六次,则时钟函数的第二次调用返回NaN。否则工作正常。
这是我的汇编代码的核心:
do_while:
push dword [eax+n]
push eax
push ecx
push dword [eax+p]
call function1
add esp,16
push dword [eax+n]
push eax
push ecx
call function2
add esp,12
fst qword[res]
push dword [eax+n]
push eax
push ecx
call function3 ;function3 returns a double precision floating
;point value
add esp,12
movsd xmm1,[res] ;xmm1=res
comisd xmm1,[eax+ex] ; eax+ex is a quadword
ja do_while
为什么结果是
clock