home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / libs / smalmath.lha / source / DPow.a < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.9 KB  |  168 lines

  1.     XDEF _IEEEDPPow
  2.  
  3. ;  Sorry this is such a maze, but I'm not all that experienced with assembly
  4. ;  language (could you tell?). Hopefully the labels are helpful -- I tried to
  5. ;  make them as clear as I could.
  6.  
  7.     SECTION code
  8.  
  9. _IEEEDPPow:
  10.     move.l        d1,-(sp)
  11.     move.l        d0,-(sp)
  12.     move.l        d3,-(sp)
  13.     move.l        d2,-(sp)
  14.     fmove.d     (sp)+,fp1
  15.     fmove.d     (sp)+,fp0
  16.     ftst.x        fp0
  17.     fbogt.w     ArgPositive
  18.     fbeq.w        ArgEQZero
  19.  
  20. ArgNegative:
  21.     fmove.x     fp2,-(sp)
  22.     fint.x        fp1,fp2
  23.     fcmp.x        fp1,fp2
  24.     fbne.w        ReturnNotANumber
  25. NegativeToInteger:
  26.     ftst.x        fp1
  27.     fmovem.l    fpsr,d0
  28.     btst.l        #25,d0
  29.     bne.w        ReturnNotANumber
  30.     fmove.x     fp3,-(sp)
  31.     fscale.w    #-1,fp2
  32.     fint.x        fp2,fp3
  33.     fcmp.x        fp2,fp3
  34.     fbeq.w        NegativeToEven
  35. NegativeToOdd:
  36.     fmove.x     (sp)+,fp3
  37.     fmove.x     (sp)+,fp2
  38.     fabs.x        fp0
  39.     flogn.x     fp0
  40.     fmul.x        fp0,fp1
  41.     fetox.x     fp1
  42.     fneg.x        fp1
  43.     fmove.d     fp1,-(sp)
  44.     movem.l     (sp)+,d0/d1
  45.     rts
  46. NegativeToEven:
  47.     fmove.x     (sp)+,fp3
  48.     fmove.x     (sp)+,fp2
  49.     fabs.x        fp0
  50.     flogn.x     fp0
  51.     fmul.x        fp0,fp1
  52.     fetox.x     fp1
  53.     fmove.d     fp1,-(sp)
  54.     movem.l     (sp)+,d0/d1
  55.     rts
  56.  
  57. ArgPositive:
  58.     flogn.x     fp0
  59.     fmul.x        fp0,fp1
  60.     fetox.x     fp1
  61.     fmove.d     fp1,-(sp)
  62.     movem.l     (sp)+,d0/d1
  63.     rts
  64.  
  65. ArgEQZero:
  66.     ftst.x        fp1
  67. ZeroToZero:
  68.     fbeq.w        ReturnNotANumberNoFP2
  69. ZeroToNonZero:
  70.     fmovem.l    fpsr,d0
  71.     btst.l        #25,d0
  72.     bne.w        ZeroToInfinity
  73. ZeroToReal:
  74.     ftst.x        fp0
  75.     fmovem.l    fpsr,d0
  76.     btst.l        #27,d0
  77.     beq.w        PositiveZeroToReal
  78. NegativeZeroToReal:
  79.     fmove.x     fp2,-(sp)
  80.     fint.x        fp1,fp2
  81.     fcmp.x        fp1,fp2
  82.     fbne.w        ReturnNotANumber
  83. NegativeZeroToInteger:
  84.     ftst.x        fp1
  85.     fmovem.l    fpsr,d0
  86.     btst.l        #25,d0
  87.     bne.w        ReturnNotANumber
  88.     fmove.x     fp3,-(sp)
  89.     fscale.w    #-1,fp2
  90.     fint.x        fp2,fp3
  91.     fcmp.x        fp2,fp3
  92.     fbeq.w        NegativeZeroToEven
  93. NegativeZeroToOdd:
  94.     fmove.x     (sp)+,fp3
  95.     ftst.x        fp1
  96.     fbogt.w     NegativeZeroToPositiveOdd
  97. NegativeZeroToNegativeOdd:
  98.     move.l        #$FFF00000,d0
  99.     clr.l        d1
  100.     fmove.x     (sp)+,fp2
  101.     rts
  102. NegativeZeroToPositiveOdd:
  103.     move.l        #$80000000,d0
  104.     clr.l        d1
  105.     fmove.x     (sp)+,fp2
  106.     rts
  107. NegativeZeroToEven:
  108.     fmove.x     (sp)+,fp3
  109.     ftst.x        fp1
  110.     fbogt.w     NegativeZeroToPositiveEven
  111. NegativeZeroToNegativeEven:
  112.     move.l        #$7FF00000,d0
  113.     clr.l        d1
  114.     fmove.x     (sp)+,fp2
  115.     rts
  116. NegativeZeroToPositiveEven:
  117.     clr.l        d0
  118.     clr.l        d1
  119.     fmove.x     (sp)+,fp2
  120.     rts
  121. PositiveZeroToReal:
  122.     ftst.x        fp1
  123.     fbogt.w     PositiveZeroToPositiveReal
  124. PositiveZeroToNegativeReal:
  125.     move.l        #$7FF00000,d0
  126.     move.l        #$0,d1
  127.     rts
  128. PositiveZeroToPositiveReal:
  129.     clr.l        d0
  130.     clr.l        d1
  131.     rts
  132. ZeroToInfinity:
  133.     btst.l        #27,d0
  134.     beq.w        ZeroToPositiveInfinity
  135. ZeroToNegativeInfinity:
  136.     ftst.x        fp0
  137.     fmovem.l    fpsr,d0
  138.     btst.l        #27,d0
  139.     beq.w        PositiveZeroToNegativeInfinity
  140. NegativeZeroToNegativeInfinity:
  141.     bra.w        ReturnNotANumberNoFP2
  142. PositiveZeroToNegativeInfinity:
  143.     move.l        #$7FF00000,d0
  144.     clr.l        d1
  145.     rts
  146. ZeroToPositiveInfinity:
  147.     ftst.x        fp0
  148.     fmovem.l    fpsr,d0
  149.     btst.l        #27,d0
  150.     beq.w        PositiveZeroToPositiveInfinity
  151. NegativeZeroToPositiveInfinity:
  152.     bra.w        ReturnNotANumberNoFP2
  153. PositiveZeroToPositiveInfinity:
  154.     clr.l        d0
  155.     clr.l        d1
  156.     rts
  157.  
  158.  
  159. ReturnNotANumber:
  160.     fmove.x     (sp)+,fp2
  161. ReturnNotANumberNoFP2:
  162.     move.l        #$7FFFFFFF,d0
  163.     move.l        #$FFFFFFFF,d1
  164.     rts
  165.  
  166.     END
  167.  
  168.