home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / zc.lzh / ZC / ZCSRC.LZH / IOLib / Math / mathtrans.a < prev    next >
Encoding:
Text File  |  1989-06-07  |  5.5 KB  |  222 lines

  1. *------------------------------------------------------------------
  2. * mathtrans.a: PDC library interface to motorola floating point
  3. * transient library base library supplied by Commodore.
  4. * Maintenance Notes:
  5. * 06Jun89 - Created by Jal
  6. *------------------------------------------------------------------
  7.  
  8. AG_OpenLib    equ $00030000
  9. AO_MathLib    equ $00008005
  10. bias    SET    -30
  11.  
  12. libref    MACRO
  13. _LVO\1    EQU    bias
  14. bias    SET    bias-6
  15.     ENDM
  16.  
  17. *------------------------------------------------------------------
  18. * Note: these *Must* be in the same order as the
  19. * mathtrans_lib.fd file.
  20. *------------------------------------------------------------------
  21.  
  22.     libref    SPAtan
  23.     libref    SPSin
  24.     libref    SPCos
  25.     libref    SPTan
  26.     libref    SPSincos
  27.     libref    SPSinh
  28.     libref    SPCosh
  29.     libref    SPTanh
  30.     libref    SPExp
  31.     libref    SPLog
  32.     libref    SPPow
  33.     libref    SPSqrt
  34.     libref    SPTieee
  35.     libref    SPFieee
  36.     libref    SPAsin
  37.     libref    SPAcos
  38.     libref    SPLog10
  39.  
  40.     XREF    _Alert
  41.     XREF    _exit
  42.     XREF    _MathTransBase
  43.     XREF    __MathTransClose
  44.     XREF    _OpenLibrary
  45.     XREF    _CloseLibrary
  46.  
  47. *------------------------------------------------------------------
  48.  
  49.     SECTION    DATA,DATA
  50.  
  51. MathTransBase    dc.l    0
  52. MATHName    dc.b    'mathtrans.library',0
  53.  
  54.     SECTION    CODE,CODE
  55.  
  56. *------------------------------------------------------------------
  57. *    Close the MathTrans library if we opened it.
  58. *------------------------------------------------------------------
  59. MathTransClose:
  60.     move.l    MathTransBase,-(A7)
  61.     jsr    _CloseLibrary
  62.     addq    #4,A7
  63.     rts
  64.  
  65. *------------------------------------------------------------------
  66. *    Open the MathTrans library
  67. *------------------------------------------------------------------
  68.  
  69. .fpopen:
  70.     movem.l D0-D1/A0-A1,-(A7)    ; save temporary registers
  71.     pea    0            ; any version will do....
  72.     pea     MATHName        ; Load the name of library
  73.     jsr    _OpenLibrary        ; Open the library
  74.     addq    #8,A7
  75.     move.l  D0,_MathTransBase    ; Save the return code
  76.     bne.s   1$            ; If non-zero then OK
  77.  
  78.     pea    0            ; Parameter for Alert.
  79.     pea    AG_OpenLib!AO_MathLib    ; Signal an error
  80.     jsr    _Alert
  81.     addq    #8,A7
  82.     pea     100            ;     push return code
  83.     jsr     _exit            ;     and exit
  84. 1$:
  85.     move.l    D0,MathTransBase
  86.     move.l    #MathTransClose,__MathTransClose
  87.     movem.l (A7)+,D0-D1/A0-A1     ; restore temporaries
  88.     rts
  89.  
  90. *------------------------------------------------------------------
  91. *    Do the MathTrans function
  92. *------------------------------------------------------------------
  93.  
  94. .fpdo:
  95.     tst.l    _MathTransBase
  96.     bne.s    1$
  97.     jsr    .fpopen
  98. 1$:
  99.     movem.l    8(A7),D0
  100.     movem.l    A6,-(A7)
  101.     move.l    _MathTransBase,A6    
  102.     add.l    4(A7),A6
  103.     jsr    (A6)
  104.     movem.l    (A7)+,A6
  105.     addq    #4,A7        ; Chuck function offset.
  106.     rts
  107.  
  108. *------------------------------------------------------------------
  109. * atan:    Input (on stack): Output D0
  110. *------------------------------------------------------------------
  111.     XDEF    _atan
  112. _atan:
  113.     pea    _LVOSPAtan
  114.     jmp    .fpdo
  115.  
  116. *------------------------------------------------------------------
  117. * sin:    Input double (on stack): Output D0
  118. *------------------------------------------------------------------
  119.     XDEF    _sin
  120. _sin:
  121.     pea    _LVOSPSin
  122.     jmp    .fpdo
  123.  
  124. *------------------------------------------------------------------
  125. * cos:    Input (on stack): Output D0
  126. *------------------------------------------------------------------
  127.     XDEF    _cos
  128. _cos:
  129.     pea    _LVOSPCos
  130.     jmp    .fpdo
  131.  
  132. *------------------------------------------------------------------
  133. * tan:    Input (on stack): Output D0
  134. *------------------------------------------------------------------
  135.     XDEF    _tan
  136. _tan:
  137.     pea    _LVOSPTan
  138.     jmp    .fpdo
  139.  
  140. *------------------------------------------------------------------
  141. * sinh:    Input (on stack): Output D0
  142. *------------------------------------------------------------------
  143.     XDEF    _sinh
  144. _sinh:
  145.     pea    _LVOSPSinh
  146.     jmp    .fpdo
  147.  
  148. *------------------------------------------------------------------
  149. * cosh:    Input (on stack): Output D0
  150. *------------------------------------------------------------------
  151.     XDEF    _cosh
  152. _cosh:
  153.     pea    _LVOSPCosh
  154.     jmp    .fpdo
  155.  
  156. *------------------------------------------------------------------
  157. * tanh:    Input (on stack): Output D0
  158. *------------------------------------------------------------------
  159.     XDEF    _tanh
  160. _tanh:
  161.     pea    _LVOSPTanh
  162.     jmp    .fpdo
  163.  
  164. *------------------------------------------------------------------
  165. * exp:    Input (on stack): Output D0
  166. *------------------------------------------------------------------
  167.     XDEF    _exp
  168. _exp:
  169.     pea    _LVOSPExp
  170.     jmp    .fpdo
  171.  
  172. *------------------------------------------------------------------
  173. * log:    Input (on stack): Output D0
  174. *------------------------------------------------------------------
  175.     XDEF    _log
  176. _log:
  177.     pea    _LVOSPLog
  178.     jmp    .fpdo
  179.  
  180. *------------------------------------------------------------------
  181. * pow:    pow(exp, power) : Output D0
  182. *------------------------------------------------------------------
  183.     XDEF    _pow
  184. _pow:
  185.     movem.l    12(A7),D1
  186.     pea    _LVOSPPow
  187.     jmp    .fpdo
  188.  
  189. *------------------------------------------------------------------
  190. * sqrt:    Input (on stack): Output D0
  191. *------------------------------------------------------------------
  192.     XDEF    _sqrt
  193. _sqrt:
  194.     pea    _LVOSPSqrt
  195.     jmp    .fpdo
  196.  
  197. *------------------------------------------------------------------
  198. * asin:    Input (on stack): Output D0
  199. *------------------------------------------------------------------
  200.     XDEF    _asin
  201. _asin:
  202.     pea    _LVOSPAsin
  203.     jmp    .fpdo
  204.  
  205. *------------------------------------------------------------------
  206. * acos:    Input (on stack): Output D0
  207. *------------------------------------------------------------------
  208.     XDEF    _acos
  209. _acos:
  210.     pea    _LVOSPAcos
  211.     jmp    .fpdo
  212.  
  213. *------------------------------------------------------------------
  214. * log10:    Input (on stack): Output D0
  215. *------------------------------------------------------------------
  216.     XDEF    _log10
  217. _log10:
  218.     pea    _LVOSPLog10
  219.     jmp    .fpdo
  220.  
  221.     END
  222.