问题描述
我们正在计算圆半径
We are computing circle radius
846: r = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
005AE147 fld qword ptr [x2]
005AE14A fsub qword ptr [x1]
005AE14D fld qword ptr [x2]
005AE150 fsub qword ptr [x1]
005AE153 fmulp st(1),st
005AE155 fld qword ptr [y2]
005AE158 fsub qword ptr [y1]
005AE15B fld qword ptr [y2]
< ---- EIP = 005AE15B下一步操作要做
<---- EIP = 005AE15B Next Operation To do
005AE15E fsub qword ptr [y1]
005AE161 fmulp st(1),st
005AE163 faddp st(1),st
005AE165 sub esp,8
005AE168 fstp qword ptr [esp]
005AE16B call _sqrt (006d0e94)
005AE170 add esp,8
005AE173 fstp qword ptr [r]
直到这里没事
Until here all right
ST0 = +0.00000000000000000e+0000
ST1 = +1.00000000000000000e+0000
ST2 = 1#IND
ST3 = 1#IND
ST4 = 1#IND
ST5 = 1#IND
ST6 = 1#IND
ST7 = 1#IND
之后
005AE15B fld qword ptr [y2]
在堆栈顶部?
after this
005AE15B fld qword ptr [y2]
at the top of the stack this?
ST0 = 1#IND
ST1 = +0.00000000000000000e+0000
ST2 = +1.00000000000000000e+0000
ST3 = 1#IND
ST4 = 1#IND
ST5 = 1#IND
ST6 = 1#IND
ST7 = 1#IND
CTRL = 027F STAT = 5A61
TAGS = A1AA EIP = 005AE15B
CS = 001B DS = 0023
编译器VC6,带有所有修补程序的Windows XP SP2,处理器Pentium m 1.7Ghz(Centrino)
Compiler VC6, Windows XP SP2 with all patches, processor Pentium m 1.7Ghz (Centrino)
推荐答案
r = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
我们称之为:
we call:
distance=me_pnt_dist_2d(p_mt->pref, pc);
if(fabs(distance-radius)<p_mt->fOsnap){
p_mt->bFind=1;
return(0);
}
return(0);
未声明me_pnt_dist_2d的地方,
where me_pnt_dist_2d was undeclared ,
double me_pnt_dist_2d(PNT_2D *p1, PNT_2D *p2);
编译器假定返回的是int,因此
我们将fabs()的值引导到
处理器处于不一致状态.
奇怪的是,代码的一部分运行良好.
846:r = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
005AE147 fld qword ptr [x2]
005AE14A fsub qword ptr [x1]
005AE14D fld qword ptr [x2]
005AE150 fsub qword ptr [x1]
005AE153 fmulp st(1),st
005AE155 fld qword ptr [y2]
005AE158 fsub qword ptr [y1]
the compiler assumes returning int, so
we call fabs() with a value that leads the
processor in an inconsistent state.
The strangeness is that part of the code works well.
846: r = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
005AE147 fld qword ptr [x2]
005AE14A fsub qword ptr [x1]
005AE14D fld qword ptr [x2]
005AE150 fsub qword ptr [x1]
005AE153 fmulp st(1),st
005AE155 fld qword ptr [y2]
005AE158 fsub qword ptr [y1]
这篇关于问题调用(未声明)函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!