示例#1
0
 def IEEESPCosh(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.cosh(arg)
   except OverflowError:
     res = float('inf')
   log_math.info("SPCosh(%s) = %s", arg, res)
   return float_to_reg(res)
示例#2
0
 def SPAcos(self,ctx):
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.acos(arg)
   except ValueError:
     res = float('-nan')
   log_math.info("SPAcos(%s) = %s", arg, res)
   return float_to_ffp_reg(res)
示例#3
0
 def IEEEDPAcos(self,ctx):
   arg = regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   try:
     res = math.acos(arg)
   except ValueError:
     res = float('-nan')
   log_math.info("DPAcos(%s) = %s", arg, res)
   return double_to_regs(res)
示例#4
0
 def IEEESPSqrt(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.sqrt(arg)
   except ValueError:
     res = float('-nan')
   log_math.info("SPSqrt(%s) = %s", arg, res)
   return float_to_reg(res)
示例#5
0
 def IEEEDPAbs(self, ctx):
     arg = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     if arg < 0.0:
         res = -arg
     else:
         res = arg
     log_math.info("DPAbs(%s) = %s", arg, res)
     return double_to_regs(res)
示例#6
0
 def IEEEDPExp(self,ctx):
   arg = regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   try:
     res = math.exp(arg)
   except OverflowError:
     res = float('inf')
   log_math.info("DPExp(%s) = %s", arg, res)
   return double_to_regs(res)
示例#7
0
 def IEEEDPCeil(self, ctx):
     arg = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     res = math.ceil(arg)
     # Amiga forces pos zero
     if res == -0.0:
         res = 0.0
     log_math.info("DPCeil(%s) = %s", arg, res)
     return double_to_regs(res)
 def IEEESPAbs(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   if arg < 0.0:
     res = -arg
   else:
     res = arg
   log_math.info("SPAbs(%s) = %s", arg, res)
   return float_to_reg(res)
示例#9
0
 def SPExp(self,ctx):
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.exp(arg)
   except OverflowError:
     res = float('inf')
   log_math.info("SPExp(%s) = %s", arg, res)
   return float_to_ffp_reg(res)
 def IEEESPCeil(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   res = math.ceil(arg)
   # Amiga forces pos zero
   if res == -0.0:
     res = 0.0
   log_math.info("SPCeil(%s) = %s", arg, res)
   return float_to_reg(res)
示例#11
0
 def IEEEDPPow(self,ctx):
   a = regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   b = regs_to_double(ctx.cpu.r_reg(REG_D2),ctx.cpu.r_reg(REG_D3))
   try:
     res = math.pow(a, b);
   except OverflowError:
     res = float('inf')
   log_math.info("DPPow(%s, %s) = %s", a, b, res)
   return double_to_regs(res)
示例#12
0
 def SPPow(self,ctx):
   a = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   b = ffp_reg_to_float(ctx.cpu.r_reg(REG_D1))
   try:
     res = math.pow(a, b);
   except OverflowError:
     res = float('inf')
   log_math.info("SPPow(%s, %s) = %s", a, b, res)
   return float_to_ffp_reg(res)
示例#13
0
 def IEEESPPow(self, ctx):
     a = reg_to_float(ctx.cpu.r_reg(REG_D0))
     b = reg_to_float(ctx.cpu.r_reg(REG_D1))
     try:
         res = math.pow(a, b)
     except OverflowError:
         res = float("inf")
     log_math.info("SPPow(%s, %s) = %s", a, b, res)
     return float_to_reg(res)
示例#14
0
 def IEEEDPFix(self, ctx):
     arg = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     if arg > Amiga_INT_MAX:
         arg = Amiga_INT_MAX
     elif arg < Amiga_INT_MIN:
         arg = Amiga_INT_MIN
     res = int(arg)
     log_math.info("DPFix(%s) = %s", arg, res)
     return res
 def IEEESPFix(self, ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   if arg > Amiga_INT_MAX:
     arg = Amiga_INT_MAX
   elif arg < Amiga_INT_MIN:
     arg = Amiga_INT_MIN
   res = int(arg)
   log_math.info("SPFix(%s) = %s", arg, res)
   return res
示例#16
0
 def IEEEDPTst(self, ctx):
     arg = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     if arg < 0.0:
         res = -1
     elif arg > 0.0:
         res = +1
     else:
         res = 0
     log_math.info("DPTst(%s) = %s", arg, res)
     return res
 def IEEESPTst(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   if arg < 0.0:
     res =  -1
   elif arg > 0.0:
     res = +1
   else:
     res = 0
   log_math.info("SPTst(%s) = %s", arg, res)
   return res
示例#18
0
 def SPLog10(self,ctx):
   arg=ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     if arg == 0.0:
       res = float('-inf')
     else:
       res = math.log10(arg)
   except ValueError:
     res = float('-nan')
   log_math.info("SPLog10(%s) = %s", arg, res)
   return float_to_ffp_reg(res)
示例#19
0
 def SPSincos(self,ctx):
   ptr = ctx.cpu.r_reg(REG_D1)
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   res_sin = math.sin(arg)
   res_cos = math.cos(arg)
   log_math.info("SPSincos(%s) = %s, %s", arg, res_sin, res_cos)
   vals_sin = float_to_ffp_reg(res_sin)
   vals_cos = float_to_ffp_reg(res_cos)
   #write cos to ptr
   ctx.mem.w32(ptr, vals_cos)
   return vals_sin
示例#20
0
 def SPAsin(self,ctx):
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.asin(arg)
   except ValueError:
     if arg < 0.0:
       res = float('nan')
     else:
       res = float('-nan')
   log_math.info("SPAsin(%s) = %s", arg, res)
   return float_to_ffp_reg(res)
示例#21
0
 def IEEEDPCmp(self, ctx):
     arg1 = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     arg2 = regs_to_double(ctx.cpu.r_reg(REG_D2), ctx.cpu.r_reg(REG_D3))
     if arg1 < arg2:
         res = -1
     elif arg1 > arg2:
         res = +1
     else:
         res = 0
     log_math.info("DPCmp(%s, %s) = %s", arg1, arg2, res)
     return res
示例#22
0
 def IEEESPLog10(self, ctx):
     arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
     try:
         if arg == 0.0:
             res = float("-inf")
         else:
             res = math.log10(arg)
     except ValueError:
         res = float("-nan")
     log_math.info("SPLog10(%s) = %s", arg, res)
     return float_to_reg(res)
示例#23
0
 def SPSinh(self,ctx):
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   try:
     res = math.sinh(arg)
   except OverflowError:
     if arg<0:
       res = float('-inf')
     else:
       res = float('inf')
   log_math.info("SPSinh(%s) = %s", arg, res)
   return float_to_ffp_reg(res)
 def IEEESPCmp(self, ctx):
   arg1 = reg_to_float(ctx.cpu.r_reg(REG_D0))
   arg2 = reg_to_float(ctx.cpu.r_reg(REG_D1))
   if arg1<arg2:
     res = -1
   elif arg1>arg2:
     res = +1
   else:
     res =  0
   log_math.info("SPCmp(%s, %s) = %s", arg1, arg2, res)
   return res
示例#25
0
 def IEEEDPSinh(self,ctx):
   arg = regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   try:
     res = math.sinh(arg)
   except OverflowError:
     if arg<0:
       res = float('-inf')
     else:
       res = float('inf')
   log_math.info("DPSinh(%s) = %s", arg, res)
   return double_to_regs(res)
示例#26
0
 def IEEEDPLog10(self,ctx):
   arg=regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   try:
     if arg == 0.0:
       res = float('-inf')
     else:
       res = math.log10(arg)
   except ValueError:
     res = float('-nan')
   log_math.info("DPLog10(%s) = %s", arg, res)
   return double_to_regs(res)
示例#27
0
 def IEEEDPSincos(self,ctx):
   ptr = ctx.cpu.r_reg(REG_A0)
   arg = regs_to_double(ctx.cpu.r_reg(REG_D0),ctx.cpu.r_reg(REG_D1))
   res_sin = math.sin(arg)
   res_cos = math.cos(arg)
   log_math.info("DPSincos(%s) = %s, %s", arg, res_sin, res_cos)
   vals_sin = double_to_regs(res_sin)
   vals_cos = double_to_regs(res_cos)
   #write cos to ptr
   ctx.mem.w32(ptr, vals_cos[0])
   ctx.mem.w32(ptr+4, vals_cos[1])
   return vals_sin
示例#28
0
 def IEEEDPDiv(self, ctx):
     arg1 = regs_to_double(ctx.cpu.r_reg(REG_D0), ctx.cpu.r_reg(REG_D1))
     arg2 = regs_to_double(ctx.cpu.r_reg(REG_D2), ctx.cpu.r_reg(REG_D3))
     if arg2 == 0.0:
         if arg1 == 0.0:
             # Amiga returns sign bit set on nan...
             res = float("-nan")
         elif arg1 > 0.0:
             res = float("inf")
         else:
             res = float("-inf")
     else:
         res = arg1 / arg2
     log_math.info("DPDiv(%s, %s) = %s", arg1, arg2, res)
     return double_to_regs(res)
 def IEEESPDiv(self,ctx):
   arg1 = reg_to_float(ctx.cpu.r_reg(REG_D0))
   arg2 = reg_to_float(ctx.cpu.r_reg(REG_D1))
   if arg2 == 0.0:
     if arg1 == 0.0:
       # Amiga returns sign bit set on nan...
       res = float('-nan')
     elif arg1 > 0.0:
       res = float('inf')
     else:
       res = float('-inf')
   else:
     res = arg1 / arg2
   log_math.info("SPDiv(%s, %s) = %s", arg1, arg2, res)
   return float_to_reg(res)
 def IEEESPFloor(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   res = math.floor(arg)
   log_math.info("SPFloor(%s) = %s", arg, res)
   return float_to_reg(res)
示例#31
0
 def SPFieee(self,ctx):
   val = ctx.cpu.r_reg(REG_D0)
   flt = reg_to_float(val)
   ffp = float_to_ffp_reg(flt)
   log_math.info("SPFieee(%s) = %08x", flt, ffp)
   return ffp
示例#32
0
 def IEEESPMul(self,ctx):
   arg1 = reg_to_float(ctx.cpu.r_reg(REG_D0))
   arg2 = reg_to_float(ctx.cpu.r_reg(REG_D1))
   res = arg1 * arg2
   log_math.info("SPMul(%s, %s) = %s", arg1, arg2, res)
   return float_to_reg(res)
 def IEEESPFieee(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   log_math.info("SPFieee(%s)", arg)
   return float_to_reg(arg)
示例#34
0
 def IEEESPFlt(self, ctx):
   i = int32(ctx.cpu.r_reg(REG_D0));
   d = float(i)
   log_math.info("SPFlt(%s) = %s", i, d)
   return float_to_reg(d)
示例#35
0
 def IEEESPNeg(self,ctx):
   arg = reg_to_float(ctx.cpu.r_reg(REG_D0))
   res = -arg
   log_math.info("SPNeg(%s) = %s", arg, res)
   return float_to_reg(res)
示例#36
0
 def SPSub(self,ctx):
   arg1 = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   arg2 = ffp_reg_to_float(ctx.cpu.r_reg(REG_D1))
   res = arg1 - arg2
   log_math.info("SPSub(%s, %s) = %s", arg1, arg2, res)
   return float_to_ffp_reg(res)
示例#37
0
 def SPTieee(self,ctx):
   val = ctx.cpu.r_reg(REG_D0)
   flt = ffp_reg_to_float(val)
   log_math.info("SPTieee(%08x) = %s", val, flt)
   return float_to_reg(flt)
示例#38
0
 def SPCeil(self,ctx):
   arg = ffp_reg_to_float(ctx.cpu.r_reg(REG_D0))
   res = math.ceil(arg)
   log_math.info("SPCeil(%s) = %s", arg, res)
   return float_to_ffp_reg(res)