This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

More on the bad 68060 floating point



The trap occurs (the pc is pointing at 5d93c [fsmovex %fp2,%fp3])
but I believe the actual fault is in [fmovecrx #15,%fp2].

Could this be an invalid 68060 instruction?

The compile line is:
    g++68k -fwritable-strings -fno-rtti -fno-exceptions -c -O3 \
	-DRTM -mshort -m68060 -DMC68060 -DMVP40 \
	 -pipe -ansi  -Adebug\(on\) -D_G_NO_EXTERN_TEMPLATES \
	 -I../../.././remote/include -I../../.././remote/localinc \
	-I../../.././remote/libinc -I../../.././remote/vcpu \
	-I../../.././remote/ppu -I../../.././include/localinc \
	-I../../.././include/libinc  \
	Udiff_hst.c -o Udiff_hst.60


the generated assembly is:
   5d908:       4e56 0000       linkw %fp,#0
   5d90c:       f227 e00c       fmovemx %fp2-%fp3,%sp@-
   5d910:       48e7 181c       moveml %d3-%d4/%a3-%a5,%sp@-
   5d914:       266e 0008       moveal %fp@(8),%a3
   5d918:       286e 000c       moveal %fp@(12),%a4
   5d91c:       262e 0010       movel %fp@(16),%d3
   5d920:       2a6e 0014       moveal %fp@(20),%a5
   5d924:       302b 0008       movew %a3@(8),%d0
   5d928:       b06c 0008       cmpw %a4@(8),%d0
   5d92c:       6644            bnes 5d972 <__th_func__FPs+5ba>
   5d92e:       43eb 000a       lea %a3@(10),%a1
   5d932:       41ec 000a       lea %a4@(10),%a0
   5d936:       4241            clrw %d1
   5d938:       f200 5d0f       fmovecrx #15,%fp2
   5d93c:       f200 09c0       fsmovex %fp2,%fp3

When generated using the -m68040 flags, the assembly is:

   0:   4856            pea %fp@
   2:   2c4f            moveal %sp,%fp
   4:   f227 e00c       fmovemx %fp2-%fp3,%sp@-
   8:   48e7 181c       moveml %d3-%d4/%a3-%a5,%sp@-
   c:   266e 0008       moveal %fp@(8),%a3
  10:   286e 000c       moveal %fp@(12),%a4
  14:   262e 0010       movel %fp@(16),%d3
  18:   2a6e 0014       moveal %fp@(20),%a5
  1c:   302b 0008       movew %a3@(8),%d0
  20:   b06c 0008       cmpw %a4@(8),%d0
  24:   6648            bnes 6e <_Udiff_khi2__FP4HibuT0PfPs+6e>
  26:   43eb 000a       lea %a3@(10),%a1
  2a:   41ec 000a       lea %a4@(10),%a0
  2e:   4241            clrw %d1
  30:   f23c 4500 0000  fmoves #0,%fp2
  36:   0000 
  38:   f200 09c0       fsmovex %fp2,%fp3

and the fmovecrx instruction is not generated.

the function is

#define NGREY   256

typedef	unsigned short u_short;

class Hibu {
public:
    u_short     h_lo;
    u_short     h_hi;
    short       h_min;
    short       h_max;
    short       h_ngrey;
    u_short     h_dat[NGREY];
};

short
Udiff_khi2(Hibu *h1, Hibu *h2, float *z, short *df)
{
    register short i;
    register u_short *s, *d;
    register float m, a, b;

    if (h1->h_ngrey != h2->h_ngrey)
        return -1;
    s = &h1->h_dat[0];
    d = &h2->h_dat[0];
    for(i=0, a=b=0; i < h1->h_ngrey; i++, s++, d++){
        a += (float) (*s);
        b += (float) (*d);
    }
    if (a < 10 || b < 10)
        return -1;
    *df = h1->h_ngrey - 1;
    a = (float) sqrt((double)(a/b));
    b = 1/a;
    s = &h1->h_dat[0];
    d = &h2->h_dat[0];
    for (i = 0, *z = 0; i < h1->h_ngrey; i++, s++, d++) {
        if((*s) == 0 && (*d) == 0)
                --(*df);
        else {
                m = b*(*s) - a*(*d);
                *z += (m*m)/((float)(*s + *d));
        }
    }
    return 0;
}
-- 
David Barto	barto@network.ucsd.edu	barto@visionpro.com
>From a Marketing type:
    Don't give me any technical reason why something can't be done.
    If you really believed in the product you'd make it work.