Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 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

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


Compiler VC6, Windows XP SP2 with all patches, processor Pentium m 1.7Ghz (Centrino)
Posted
Updated 17-May-10 0:16am
v3
Comments
Moak 17-May-10 6:18am    
Updated subject and tags, hope this helps to get more answers.

1 solution

Find the causes of the problem:

Before execution of:

r  = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); 


we call:

C#
distance=me_pnt_dist_2d(p_mt->pref, pc);
if(fabs(distance-radius)<p_mt->fOsnap){
    p_mt->bFind=1;
    return(0);
}
return(0);


where me_pnt_dist_2d was undeclared ,

double me_pnt_dist_2d(PNT_2D *p1, PNT_2D *p2);


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]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900