From: Daniel M. <sd...@bl...> - 2013-02-20 12:08:16
|
[resent after sending from the wrong mail address earlier] On Wed, Feb 20, 2013 at 12:05:15PM +0100, Daniel Michalik wrote: > The asm block "functions called" is identical expect for the additional > "___slong2fs" in the not working example. I am not sure whether that is > sufficient indication to consider ___slong2fs the culprit, or whether I > can perform any additional tests. > > When starting with 100 I obtain 144, for 116 I obtain 208, not sure that > this makes any sense. I guess it is time to look closer into slong2fs, > but I find different source files in the sdcc tree. Exciting, I found it ... :) Maybe that's just part of the solution, but I find that sdcc/device/lib/pic14/libsdcc/ulong2fs.c if(a < HIDDEN) { do { a<<=1; exp--; } while (a < HIDDEN); } causes the problem. Right underneath I find a commented piece of code - why was it commented in the first place? I replaced the version above by the part below, without the ifdef, now my example works. #if 0 while (a < HIDDEN) { a <<= 1; exp--; } #endif I then looked in sdcc/devices/lib/_ulong2fs.c, which also uses the bottom version. Why do different devices have copies of (almost) the same code in various places? Shouldn't they all use the same to avoid situations like this? Is there any kind of unit or regression test that we can add to avoid this coming back? Since I am not a developer but merely a user of few weeks experience, can I ask someone on this list to help me by bringing in the fix (and a test if possible)? It might also be desirable to review the other implementations of the same function, as far as more exist. Kind regards, //Daniel |