More FP

A project log for Merlin

68000 Retro Super Computer

Matthew PearceMatthew Pearce 08/16/2021 at 08:300 Comments

I have a 64-bit double precision FPU working now. It seems to be a big improvement on my first version. The main work now is to complete the new library for GCC to make use of the FPU.

I have started to work on a set of wrapper functions which will override the existing soft-float routines.

The first routine overrides muldf3:

double __wrap___muldf3(double a, double b)

  printf("\r\nmuldf3: start\r\n");

  *fpu_ctl = MUL;

  op_a.dbl = a;
  op_b.dbl = b;

  *opa = op_a.num;
  *opb = op_b.num;

  BIT_SET(*fpu_ctl, 0);
  BIT_CLEAR(*fpu_ctl, 0);

  while (!BIT_CHECK(*fpu_sts, 0) && !BIT_CHECK(*fpu_sts, 1))

  resf.num = *fpu_res;

  printf("\r\nmuldf3: stop\r\n");

  return resf.dbl;

It uses a union to convert the double to IEEE754 double-precision int.

union FloatingPointIEEE754
    unsigned int sign : 1;
    unsigned short int exponent : 11;
    long long mantissa : 52;
  } raw;
  uint64_t num;
  double dbl;
} ;

The make file has an additional parameter to override the specified function. ieee754.c float-test.c
	m68k-elf-gcc -Wall -m68000 -g -Os ieee754.c float-test.c 
-Wl,--wrap=__muldf3 -o ....