Help save net neutrality! Learn more.

#856 powf regression on mcs51-large


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.

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

Tested with version: SDCC :
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 for more info.


  • Paul Stoffregen

    Paul Stoffregen - 2005-01-04

    Sample code and Makefile that runs it with ucsim

  • Erik Petrich

    Erik Petrich - 2005-01-25

    Logged In: YES

    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

Log in to post a comment.