Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#856 powf regression on mcs51-large

closed-fixed
Erik Petrich
5
2013-05-25
2005-01-04
Paul Stoffregen
No

Looks like my new expf() and logf() broke the powf
regression test on mcs51 large model. But these work
fine when I test them with the same input as the
regression test uses.

Here is some shorter sample code that demonstrates the
problem. A Makefile is included which builds this
simple, single-file test case and runs it with ucsim.

http://www.pjrc.com/tmp/powf_bug.tar.gz

Just type "make" to build the code and see its output
via ucsim.

Tested with version: SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.4.7 #920 (Jan 4 2005) (UNIX)

The output looks like this:

Correct output should be:
1.5^2 = 2.2500000
1.5^2 = 0x40100000

Actual output is:
1.5^2 = -39063.2421875
1.5^2 = 0xC718973E

If the unused code is removed (see comments), the
correct output is produced.

I'm still working on this, but it's very mysterious.
If anyone complains about the regression, I'll probably
switch the library back to the old C versions of logf
and expf (if that happens, edit #defines math.h and
rebuild sdcc). Hard to tell if this bug is in these
new functions or somewhere else.

Contact paul AT pjrc.com for more info.

Discussion

  • Sample code and Makefile that runs it with ucsim

     
    Attachments
  • Erik Petrich
    Erik Petrich
    2005-01-25

    Logged In: YES
    user_id=635249

    Fixed in device/lib/expf.c 1.5 (SDCC version 2.4.8 #941)

    The static variable n was allocated in xdata (at least under
    the large model), but always accessed in data, thus clashing
    with other variables. With the unused code removed, there
    still is some corruption, just not with anything critical to
    the result of your sample code.

     
  • Erik Petrich
    Erik Petrich
    2005-01-25

    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed