Subject: fscalel emulation problem
To: port-mac68k , ADAMGOOD <ADAMGOOD@delphi.com>
From: Norman Mackenzie <101564.312@compuserve.com>
List: port-mac68k
Date: 09/30/1997 19:22:51
(I don't subscribe to this list, I download the archives, so if this
problem has been addressed since my last download, sorry.)

I think there is a problem in the file
/usr/src/sys/arch/m68k/fpe/fpu_fscale.c that causes emulated fscalel
instructions to fail silently.  Round about line 150 the lines

        if (format == FTYPE_LNG) {
            /* nothing */
        } else if (format == FTYPE_WRD) {

should have a line added 

        if (format == FTYPE_LNG) {
            /* something */
            scale = buf[0];
        } else if (format == FTYPE_WRD) {

This problem affects GhostScript on an FPUless machine, since that program
does conversions between floating and fixed point numbers using 4096 as a
base and gcc converts that to an fscalel.  The effect is that everything is
4096 times too small and things like the clip path are rounded to zero.
(There may be other reasons why GhostScript doesn't work, I haven't tried
it with this fix yet.)

I've just noticed that further down the lines

        } else if (format == FTYPE_DBL || format == FTYPE_SNG ||
                   format == FTYPE_EXT) {
            fpu_explode(fe, &fe->fe_f2, format, buf);
            fpu_implode(fe, &fe->fe_f2, FTYPE_LNG, buf);
        }

should probably be changed to get the long value from buf into scale, but I
haven't actually tested that.  Perhaps just 

        } else if (format == FTYPE_DBL || format == FTYPE_SNG ||
                   format == FTYPE_EXT) {
            fpu_explode(fe, &fe->fe_f2, format, buf);
            fpu_implode(fe, &fe->fe_f2, FTYPE_LNG, buf);
            scale =  buf[0];
        }

would work.  I would need to check how fpu_implode() works before being
sure.

Norman