Have you tried the latest snapshot? What version are you using? To find the version you are using, please try:
sdcc -v I had the same problem last week, but I think I fixed the bug (revision 4475 and up). You can check the bug report here: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1599523&group_id=599 What I did was to force the return value of expf() to be always positive. The problem was only present in the optimized assembly version of expf(). I suspect the problem occurs for any negative value between 0 and -0.69314718. The c version works fine. If you want to use the c version of expf() you'll need to recompile the library function: sdcc -UMATH_ASM_MCS51 expf.c or just get the latest sdcc snapshot from http://sdcc.sourceforge.net/ If everything is right, then the problem maybe in the declaration of SignalRef. Is that an array of integers or chars? Remember 512*exp(0.0)=512 which doesn't fit in a char. Jesús At 02:59 AM 29/11/2006, you wrote: >Hello, > > >My name is Maurizio Tognolini and I work in the Geneva Engineering >School (Switzerland). In my group we testing now the SDCC free c >compiler on our micro controller based control system, and we encounter >some difficulties. We use as debugger en code loader the IDE free >development environment from Silicon Laboratories. > >We observe an abnormal behavior using *expf *function with SDCC >compiler (last release). >We compile the c source code for the 8051F120 micro controller from >Cygnal, with the following compilation directives: > >The c compiler options: >-c --debug --use-stdout -V --model-large > >The linker options: >--debug --use-stdout -V --model-large --no-xinit-opt > >the assembler options: >-plosgff --model-large --xdata-loc > >*The problem: * >if the argument of the expf() function is negative the result sign is >wrong (negative) for the arguments values between -0.1/3 and -2.0/3. >bellow you can find the source code of the function who use the expf in >order to compute a table of decreasing exp. >A dump of memory is attached (dumpSignalRef.txt) containing the numbers >in SignalRef[] table), the first value is OK but the following are >wrong (negative). > >We can solve this problem using positive argument in the expression >1/expf() but we need to understand why this happens. > >Last question: Do you know a debugger based on SDCC compiler for MCS51 >family ? > >Thanks for your help. > >Sincerely > >M.Tognolini >Ecole d'Ingénieurs de Genève >1202 Genève >Suisse > >Tel 0041 22 3380565 > > > >#define NBR_POINTS 100 // Nombre de points du signal de >reference >#define AMPLITUDE (float)512.0 // Amplitude du signal de >reference > >void SignalSinusAmorti(void) > >{ > static float arg; > char I; > > arg = 0.0; > > for (I = 0; I < NBR_POINTS; I++) > { > SignalRef[I] = (int)(AMPLITUDE *expf(arg)); >//*sinf(OMEGA*t+5*PI) + 0.5 ); > arg = arg - 0.033333; > } >} > > > > > > >00 >02 >11 >fe >22 >fe >31 >fe >40 >fe >4f >fe >5d >fe >6b >fe >78 >fe >85 >fe >92 >fe >9e >fe >a9 >fe >b5 >fe >bf >fe >ca >fe >d4 >fe >de >fe >e8 >fe >f1 >fe >fa >fe >fe >00 >f5 >00 >ed >00 >e6 >00 >de >00 >d7 >00 >d0 >00 >c9 >00 >c2 >00 >bc >00 >b6 >00 >b0 >00 >aa >00 >a4 >00 >9f >00 >9a >00 >95 >00 >90 >00 >8b >00 >86 >00 >82 >00 >7e >00 >7a >00 >76 >00 >72 >00 >6e >00 >6a >00 >67 >00 >63 >00 >60 >00 >5d >00 >5a >00 >57 >00 >54 >00 >51 >00 >4f >00 >4c >00 >4a >00 >47 >00 >45 >00 >43 >00 >40 >00 >3e >00 >3c >00 >3a >00 >38 >00 >36 >00 >35 >00 >33 >00 >31 >00 >30 >00 >2e >00 >2c >00 >2b >00 >2a >00 >28 >00 >27 >00 >26 >00 >24 >00 >23 >00 >22 >00 >21 >00 >20 >00 >1f >00 >1e >00 >1d >00 >1c >00 >1b >00 >1a >00 >19 >00 >18 >00 >17 >00 >17 >00 >16 >00 >15 >00 >14 >00 >14 >00 >13 >00 >12 >00 >29 > > >------------------------------------------------------------------------- >Take Surveys. Earn Cash. Influence the Future of IT >Join SourceForge.net's Techsay panel and you'll get the chance to share your >opinions on IT & business topics through brief surveys - and earn cash >http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >_______________________________________________ >Sdcc-user mailing list >Sdcc-user@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/sdcc-user ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user