Ejemplo n.º 1
0
static inline
void storeDouble(const unsigned int Fn,unsigned int *pMem)
{
   FPA11 *fpa11 = GET_FPA11();
   union
   {
     float64 f;
     unsigned int i[2];
   } val;

   switch (fpa11->fType[Fn])
   {
      case typeSingle:
         val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle);
      break;

      case typeExtended:
         val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
      break;

      default: val.f = fpa11->fpreg[Fn].fDouble;
   }

   put_user(val.i[1], &pMem[0]);	/* msw */
   put_user(val.i[0], &pMem[1]);	/* lsw */
}
Ejemplo n.º 2
0
static inline void storeDouble(struct roundingData *roundData, const unsigned int Fn, unsigned int __user *pMem)
{
	FPA11 *fpa11 = GET_FPA11();
	union {
		float64 f;
		unsigned int i[2];
	} val;

	switch (fpa11->fType[Fn]) {
	case typeSingle:
		val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle);
		break;

#ifdef CONFIG_FPE_NWFPE_XP
	case typeExtended:
		val.f = floatx80_to_float64(roundData, fpa11->fpreg[Fn].fExtended);
		break;
#endif

	default:
		val.f = fpa11->fpreg[Fn].fDouble;
	}

#ifdef __ARMEB__
	put_user(val.i[0], &pMem[0]);	/* msw */
	put_user(val.i[1], &pMem[1]);	/* lsw */
#else
	put_user(val.i[1], &pMem[0]);	/* msw */
	put_user(val.i[0], &pMem[1]);	/* lsw */
#endif
}
extern __inline__
void storeDouble(const unsigned int Fn,unsigned int *pMem)
{
   float64 val;
   register unsigned int *p = (unsigned int*)&val;

   switch (fpa11->fType[Fn])
   {
      case typeSingle: 
         val = float32_to_float64(fpa11->fpreg[Fn].fSingle);
      break;

      case typeExtended:
         val = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
      break;

      default: val = fpa11->fpreg[Fn].fDouble;
   }
#ifdef __ARMEB__
   put_user(p[0], &pMem[0]);	/* msw */
   put_user(p[1], &pMem[1]);	/* lsw */
#else
   put_user(p[1], &pMem[0]);	/* msw */
   put_user(p[0], &pMem[1]);	/* lsw */
#endif
}   
Ejemplo n.º 4
0
static inline
void storeDouble(const unsigned int Fn, target_ulong addr)
{
   FPA11 *fpa11 = GET_FPA11();
   float64 val;
   register unsigned int *p = (unsigned int*)&val;

   switch (fpa11->fType[Fn])
   {
      case typeSingle:
         val = float32_to_float64(fpa11->fpreg[Fn].fSingle, &fpa11->fp_status);
      break;

      case typeExtended:
         val = floatx80_to_float64(fpa11->fpreg[Fn].fExtended, &fpa11->fp_status);
      break;

      default: val = fpa11->fpreg[Fn].fDouble;
   }
   /* FIXME - handle put_user() failures */
#ifdef HOST_WORDS_BIGENDIAN
   put_user_u32(p[0], addr);	/* msw */
   put_user_u32(p[1], addr + 4);	/* lsw */
#else
   put_user_u32(p[1], addr);	/* msw */
   put_user_u32(p[0], addr + 4);	/* lsw */
#endif
}
Ejemplo n.º 5
0
float64 __truncxfdf2(long_double A)
{
#if __SIZEOF_LONG_DOUBLE__ == 12
	return floatx80_to_float64(A);
#else
	return float128_to_float64(A);
#endif
}
Ejemplo n.º 6
0
INLINE double fx80_to_double(floatx80 fx)
{
	UINT64 d;
	double *foo;

	foo = (double *)&d;

	d = floatx80_to_float64(fx);

	return *foo;
}
Ejemplo n.º 7
0
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::FST_DOUBLE_REAL(bxInstruction_c *i)
{
  BX_CPU_THIS_PTR prepareFPU(i);

  RMAddr(i) = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));

  FPU_update_last_instruction(i);

  Bit16u x87_sw = FPU_PARTIAL_STATUS;

  clear_C1();

  float64 save_reg = float64_default_nan; /* The masked response */

  int pop_stack = i->nnn() & 1;

  if (IS_TAG_EMPTY(0))
  {
     FPU_exception(FPU_EX_Stack_Underflow);

     if (! BX_CPU_THIS_PTR the_i387.is_IA_masked())
        BX_NEXT_INSTR(i);
  }
  else
  {
     float_status_t status =
         FPU_pre_exception_handling(BX_CPU_THIS_PTR the_i387.get_control_word());

     save_reg = floatx80_to_float64(BX_READ_FPU_REG(0), status);

     if (FPU_exception(status.float_exception_flags, 1))
        BX_NEXT_INSTR(i);
  }

  // store to the memory might generate an exception, in this case origial FPU_SW must be kept
  swap_values16u(x87_sw, FPU_PARTIAL_STATUS);

  write_virtual_qword(i->seg(), RMAddr(i), save_reg);

  FPU_PARTIAL_STATUS = x87_sw;
  if (pop_stack)
     BX_CPU_THIS_PTR the_i387.FPU_pop();

  BX_NEXT_INSTR(i);
}
Ejemplo n.º 8
0
static inline
void storeDouble(const unsigned int Fn,unsigned int *pMem)
{
   FPA11 *fpa11 = GET_FPA11();
   float64 val;
   register unsigned int *p = (unsigned int*)&val;

   switch (fpa11->fType[Fn])
   {
      case typeSingle: 
         val = float32_to_float64(fpa11->fpreg[Fn].fSingle);
      break;

      case typeExtended:
         val = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
      break;

      default: val = fpa11->fpreg[Fn].fDouble;
   }
   put_user(p[1], &pMem[0]);	/* msw */
   put_user(p[0], &pMem[1]);	/* lsw */
}   
Ejemplo n.º 9
0
void BX_CPP_AttrRegparmN(1) BX_CPU_C::FST_DOUBLE_REAL(bxInstruction_c *i)
{
#if BX_SUPPORT_FPU
  BX_CPU_THIS_PTR prepareFPU(i);

  clear_C1();

  float64 save_reg = float64_default_nan; /* The masked response */

  int pop_stack = i->nnn() & 1;

  if (IS_TAG_EMPTY(0))
  {
     BX_CPU_THIS_PTR FPU_exception(FPU_EX_Stack_Underflow);

     if (! (BX_CPU_THIS_PTR the_i387.is_IA_masked()))
        return;
  }
  else
  {
     float_status_t status =
         FPU_pre_exception_handling(BX_CPU_THIS_PTR the_i387.get_control_word());

     save_reg = floatx80_to_float64(BX_READ_FPU_REG(0), status);

     if (BX_CPU_THIS_PTR FPU_exception(status.float_exception_flags))
        return;
  }

  write_virtual_qword(i->seg(), RMAddr(i), save_reg);

  if (pop_stack)
     BX_CPU_THIS_PTR the_i387.FPU_pop();
#else
  BX_INFO(("FST(P)_DOUBLE_REAL: required FPU, configure --enable-fpu"));
#endif
}
Ejemplo n.º 10
0
unsigned int EmulateCPDO(const unsigned int opcode)
{
    FPA11 *fpa11 = GET_FPA11();
    FPREG *rFd;
    unsigned int nType, nDest, nRc;
    struct roundingData roundData;

    /* Get the destination size.  If not valid let Linux perform
       an invalid instruction trap. */
    nDest = getDestinationSize(opcode);
    if (typeNone == nDest)
        return 0;

    roundData.mode = SetRoundingMode(opcode);
    roundData.precision = SetRoundingPrecision(opcode);
    roundData.exception = 0;

    /* Compare the size of the operands in Fn and Fm.
       Choose the largest size and perform operations in that size,
       in order to make use of all the precision of the operands.
       If Fm is a constant, we just grab a constant of a size
       matching the size of the operand in Fn. */
    if (MONADIC_INSTRUCTION(opcode))
        nType = nDest;
    else
        nType = fpa11->fType[getFn(opcode)];

    if (!CONSTANT_FM(opcode)) {
        register unsigned int Fm = getFm(opcode);
        if (nType < fpa11->fType[Fm]) {
            nType = fpa11->fType[Fm];
        }
    }

    rFd = &fpa11->fpreg[getFd(opcode)];

    switch (nType) {
    case typeSingle:
        nRc = SingleCPDO(&roundData, opcode, rFd);
        break;
    case typeDouble:
        nRc = DoubleCPDO(&roundData, opcode, rFd);
        break;
#ifdef CONFIG_FPE_NWFPE_XP
    case typeExtended:
        nRc = ExtendedCPDO(&roundData, opcode, rFd);
        break;
#endif
    default:
        nRc = 0;
    }

    /* The CPDO functions used to always set the destination type
       to be the same as their working size. */

    if (nRc != 0) {
        /* If the operation succeeded, check to see if the result in the
           destination register is the correct size.  If not force it
           to be. */

        fpa11->fType[getFd(opcode)] = nDest;

#ifdef CONFIG_FPE_NWFPE_XP
        if (nDest != nType) {
            switch (nDest) {
            case typeSingle:
                {
                    if (typeDouble == nType)
                        rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
                    else
                        rFd->fSingle = floatx80_to_float32(&roundData, rFd->fExtended);
                }
                break;

            case typeDouble:
                {
                    if (typeSingle == nType)
                        rFd->fDouble = float32_to_float64(rFd->fSingle);
                    else
                        rFd->fDouble = floatx80_to_float64(&roundData, rFd->fExtended);
                }
                break;

            case typeExtended:
                {
                    if (typeSingle == nType)
                        rFd->fExtended = float32_to_floatx80(rFd->fSingle);
                    else
                        rFd->fExtended = float64_to_floatx80(rFd->fDouble);
                }
                break;
            }
        }
#else
        if (nDest != nType) {
            if (nDest == typeSingle)
                rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
            else
                rFd->fDouble = float32_to_float64(rFd->fSingle);
        }
#endif
    }

    if (roundData.exception)
        float_raise(roundData.exception);

    return nRc;
}
Ejemplo n.º 11
0
unsigned int EmulateCPDO(const unsigned int opcode)
{
   FPA11 *fpa11 = GET_FPA11();
   unsigned int Fd, nType, nDest, nRc = 1;

   //printk("EmulateCPDO(0x%08x)\n",opcode);

   /* Get the destination size.  If not valid let Linux perform
      an invalid instruction trap. */
   nDest = getDestinationSize(opcode);
   if (typeNone == nDest) return 0;

   SetRoundingMode(opcode);

   /* Compare the size of the operands in Fn and Fm.
      Choose the largest size and perform operations in that size,
      in order to make use of all the precision of the operands.
      If Fm is a constant, we just grab a constant of a size
      matching the size of the operand in Fn. */
   if (MONADIC_INSTRUCTION(opcode))
     nType = nDest;
   else
     nType = fpa11->fType[getFn(opcode)];

   if (!CONSTANT_FM(opcode))
   {
     register unsigned int Fm = getFm(opcode);
     if (nType < fpa11->fType[Fm])
     {
        nType = fpa11->fType[Fm];
     }
   }

   switch (nType)
   {
      case typeSingle   : nRc = SingleCPDO(opcode);   break;
      case typeDouble   : nRc = DoubleCPDO(opcode);   break;
      case typeExtended : nRc = ExtendedCPDO(opcode); break;
      default           : nRc = 0;
   }

   /* If the operation succeeded, check to see if the result in the
      destination register is the correct size.  If not force it
      to be. */
   Fd = getFd(opcode);
   nType = fpa11->fType[Fd];
   if ((0 != nRc) && (nDest != nType))
   {
     switch (nDest)
     {
       case typeSingle:
       {
         if (typeDouble == nType)
           fpa11->fpreg[Fd].fSingle =
              float64_to_float32(fpa11->fpreg[Fd].fDouble, &fpa11->fp_status);
         else
           fpa11->fpreg[Fd].fSingle =
              floatx80_to_float32(fpa11->fpreg[Fd].fExtended, &fpa11->fp_status);
       }
       break;

       case typeDouble:
       {
         if (typeSingle == nType)
           fpa11->fpreg[Fd].fDouble =
              float32_to_float64(fpa11->fpreg[Fd].fSingle, &fpa11->fp_status);
         else
           fpa11->fpreg[Fd].fDouble =
              floatx80_to_float64(fpa11->fpreg[Fd].fExtended, &fpa11->fp_status);
       }
       break;

       case typeExtended:
       {
         if (typeSingle == nType)
           fpa11->fpreg[Fd].fExtended =
              float32_to_floatx80(fpa11->fpreg[Fd].fSingle, &fpa11->fp_status);
         else
           fpa11->fpreg[Fd].fExtended =
              float64_to_floatx80(fpa11->fpreg[Fd].fDouble, &fpa11->fp_status);
       }
       break;
     }

     fpa11->fType[Fd] = nDest;
   }

   return nRc;
}
Ejemplo n.º 12
0
static void fmove_reg_mem(m68000_base_device *m68k, UINT16 w2)
{
	int ea = m68k->ir & 0x3f;
	int src = (w2 >>  7) & 0x7;
	int dst = (w2 >> 10) & 0x7;
	int k = (w2 & 0x7f);

	switch (dst)
	{
		case 0:     // Long-Word Integer
		{
			INT32 d = (INT32)floatx80_to_int32(REG_FP(m68k)[src]);
			WRITE_EA_32(m68k, ea, d);
			break;
		}
		case 1:     // Single-precision Real
		{
			UINT32 d = floatx80_to_float32(REG_FP(m68k)[src]);
			WRITE_EA_32(m68k, ea, d);
			break;
		}
		case 2:     // Extended-precision Real
		{
			WRITE_EA_FPE(m68k, ea, REG_FP(m68k)[src]);
			break;
		}
		case 3:     // Packed-decimal Real with Static K-factor
		{
			// sign-extend k
			k = (k & 0x40) ? (k | 0xffffff80) : (k & 0x7f);
			WRITE_EA_PACK(m68k, ea, k, REG_FP(m68k)[src]);
			break;
		}
		case 4:     // Word Integer
		{
			int32 value = floatx80_to_int32(REG_FP(m68k)[src]);
			if (value > 0x7fff || value < -0x8000 )
			{
				REG_FPSR(m68k) |= FPES_OE | FPAE_IOP;
			}
			WRITE_EA_16(m68k, ea, (INT16)value);
			break;
		}
		case 5:     // Double-precision Real
		{
			UINT64 d;

			d = floatx80_to_float64(REG_FP(m68k)[src]);

			WRITE_EA_64(m68k, ea, d);
			break;
		}
		case 6:     // Byte Integer
		{
			int32 value = floatx80_to_int32(REG_FP(m68k)[src]);
			if (value > 127 || value < -128)
			{
				REG_FPSR(m68k) |= FPES_OE | FPAE_IOP;
			}
			WRITE_EA_8(m68k, ea, (INT8) value);
			break;
		}
		case 7:     // Packed-decimal Real with Dynamic K-factor
		{
			WRITE_EA_PACK(m68k, ea, REG_D(m68k)[k>>4], REG_FP(m68k)[src]);
			break;
		}
	}

	m68k->remaining_cycles -= 12;
}