home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / hce.lha / HCE / LibSource / clib / Math / src / mathtrans.a < prev   
Encoding:
Text File  |  1992-09-02  |  6.1 KB  |  256 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. * 28May90 - Modifications by TETISOFT
  7. * 16Jan91 - TetiSoft commented out saving of A6 with ';'
  8. *           since HCC does not use it as local stack pointer.
  9. *           Changed Alert Code, since we have Intuition open,
  10. *           we can use text instead of numbers.
  11. *
  12. *------------------------------------------------------------------
  13.  
  14. ;AG_OpenLib    equ    $00030000
  15. ;AO_MathLib    equ    $00008005
  16. bias        SET    -30
  17.  
  18. libref    MACRO
  19. _LVO\1    EQU    bias
  20. bias    SET    bias-6
  21.     ENDM
  22.  
  23. *------------------------------------------------------------------
  24. * Note: these *Must* be in the same order as the
  25. * mathtrans_lib.fd file.
  26. *------------------------------------------------------------------
  27.  
  28.     libref    SPAtan
  29.     libref    SPSin
  30.     libref    SPCos
  31.     libref    SPTan
  32.     libref    SPSincos
  33.     libref    SPSinh
  34.     libref    SPCosh
  35.     libref    SPTanh
  36.     libref    SPExp
  37.     libref    SPLog
  38.     libref    SPPow
  39.     libref    SPSqrt
  40.     libref    SPTieee
  41.     libref    SPFieee
  42.     libref    SPAsin
  43.     libref    SPAcos
  44.     libref    SPLog10
  45.  
  46. ;    XREF    _Alert
  47.     XREF    _DisplayAlert
  48.  
  49.     XREF    _exit
  50.     XREF    _OpenLibrary
  51.     XREF    _CloseLibrary
  52.     XREF    __MathTransClose
  53.  
  54.     XDEF    _MathTransBase
  55.  
  56. *------------------------------------------------------------------
  57.  
  58.     DATA
  59.  
  60. MATHName        DC.B    'mathtrans.library',0
  61.  
  62.     EVEN
  63. AlertString:
  64.     DC.W    120    ; x-Offset
  65.     DC.B    20    ; y-Offset
  66.     DC.B    'Could not open mathtrans.library.',0
  67.     DC.B    1    ; another Text follows...
  68.     DC.B    0,120    ; x
  69.     DC.B    40    ; y
  70.     DC.B    'Press a mouse button to exit.',0,0
  71.  
  72.     BSS
  73.  
  74. MathTransBase        DS.L    1
  75. _MathTransBase        DS.L    1
  76.  
  77.     CODE
  78.  
  79. *------------------------------------------------------------------
  80. *    Close the MathTrans library if we opened it.
  81. *------------------------------------------------------------------
  82. MathTransClose:
  83.     move.l    MathTransBase,-(sp)
  84.     jsr    _CloseLibrary
  85.     addq    #4,sp
  86.     rts
  87.  
  88. *------------------------------------------------------------------
  89. *    Open the MathTrans library
  90. *------------------------------------------------------------------
  91.  
  92. .fpopen:
  93.     movem.l    D0-D1/A0-A1,-(sp)    ; save temporary registers
  94.     pea    0            ; any version will do....
  95.     pea    MATHName        ; Load the name of library
  96.     jsr    _OpenLibrary        ; Open the library
  97.     addq    #8,sp
  98.     move.l    D0,_MathTransBase    ; Save the return code
  99.     bne.s    1$            ; If non-zero then OK
  100.  
  101. ;    pea    0            ; Parameter for Alert.
  102. ;    pea    AG_OpenLib!AO_MathLib    ; Signal an error
  103. ;    jsr    _Alert
  104. ;    addq    #8,sp
  105.  
  106.     pea    60        ; Height
  107.     pea    AlertString
  108.     pea    0        ; RECOVERY_ALERT
  109.     jsr    _DisplayAlert
  110.     lea    12(sp),sp
  111.  
  112.     pea    100            ;    push return code
  113.     jsr    _exit            ;    and exit
  114. 1$:
  115.     move.l    D0,MathTransBase
  116.     move.l    #MathTransClose,__MathTransClose
  117.     movem.l    (sp)+,D0-D1/A0-A1        ; restore temporaries
  118.     rts
  119.  
  120. *------------------------------------------------------------------
  121. *    Do the MathTrans function
  122. *------------------------------------------------------------------
  123.  
  124. .fpdo:
  125.     tst.l    _MathTransBase
  126.     bne.s    1$
  127.     jsr    .fpopen
  128. 1$:
  129.     movem.l    8(sp),D0
  130. ;    movem.l    A6,-(sp)
  131.     move.l    _MathTransBase,A6    
  132.  
  133. ; TetiSoft We changed the stack frame...
  134. ;    add.l    4(sp),A6
  135.     add.l    (sp),A6
  136.  
  137.     jsr    (A6)
  138. ;    movem.l    (sp)+,A6
  139.     addq    #4,sp        ; Chuck function offset.
  140.     rts
  141.  
  142. *------------------------------------------------------------------
  143. * atan:    Input (on stack): Output D0
  144. *------------------------------------------------------------------
  145.     XDEF    _atan
  146. _atan:
  147.     pea    _LVOSPAtan
  148.     jmp    .fpdo
  149.  
  150. *------------------------------------------------------------------
  151. * sin:    Input double (on stack): Output D0
  152. *------------------------------------------------------------------
  153.     XDEF    _sin
  154. _sin:
  155.     pea    _LVOSPSin
  156.     jmp    .fpdo
  157.  
  158. *------------------------------------------------------------------
  159. * cos:    Input (on stack): Output D0
  160. *------------------------------------------------------------------
  161.     XDEF    _cos
  162. _cos:
  163.     pea    _LVOSPCos
  164.     jmp    .fpdo
  165.  
  166. *------------------------------------------------------------------
  167. * tan:    Input (on stack): Output D0
  168. *------------------------------------------------------------------
  169.     XDEF    _tan
  170. _tan:
  171.     pea    _LVOSPTan
  172.     jmp    .fpdo
  173.  
  174. *------------------------------------------------------------------
  175. * sinh:    Input (on stack): Output D0
  176. *------------------------------------------------------------------
  177.     XDEF    _sinh
  178. _sinh:
  179.     pea    _LVOSPSinh
  180.     jmp    .fpdo
  181.  
  182. *------------------------------------------------------------------
  183. * cosh:    Input (on stack): Output D0
  184. *------------------------------------------------------------------
  185.     XDEF    _cosh
  186. _cosh:
  187.     pea    _LVOSPCosh
  188.     jmp    .fpdo
  189.  
  190. *------------------------------------------------------------------
  191. * tanh:    Input (on stack): Output D0
  192. *------------------------------------------------------------------
  193.     XDEF    _tanh
  194. _tanh:
  195.     pea    _LVOSPTanh
  196.     jmp    .fpdo
  197.  
  198. *------------------------------------------------------------------
  199. * exp:    Input (on stack): Output D0
  200. *------------------------------------------------------------------
  201.     XDEF    _exp
  202. _exp:
  203.     pea    _LVOSPExp
  204.     jmp    .fpdo
  205.  
  206. *------------------------------------------------------------------
  207. * log:    Input (on stack): Output D0
  208. *------------------------------------------------------------------
  209.     XDEF    _log
  210. _log:
  211.     pea    _LVOSPLog
  212.     jmp    .fpdo
  213.  
  214. *------------------------------------------------------------------
  215. * pow:    pow(exp, power) : Output D0
  216. *------------------------------------------------------------------
  217.     XDEF    _pow
  218. _pow:
  219.     movem.l    12(sp),D1
  220.     pea    _LVOSPPow
  221.     jmp    .fpdo
  222.  
  223. *------------------------------------------------------------------
  224. * sqrt:    Input (on stack): Output D0
  225. *------------------------------------------------------------------
  226.     XDEF    _sqrt
  227. _sqrt:
  228.     pea    _LVOSPSqrt
  229.     jmp    .fpdo
  230.  
  231. *------------------------------------------------------------------
  232. * asin:    Input (on stack): Output D0
  233. *------------------------------------------------------------------
  234.     XDEF    _asin
  235. _asin:
  236.     pea    _LVOSPAsin
  237.     jmp    .fpdo
  238.  
  239. *------------------------------------------------------------------
  240. * acos:    Input (on stack): Output D0
  241. *------------------------------------------------------------------
  242.     XDEF    _acos
  243. _acos:
  244.     pea    _LVOSPAcos
  245.     jmp    .fpdo
  246.  
  247. *------------------------------------------------------------------
  248. * log10:    Input (on stack): Output D0
  249. *------------------------------------------------------------------
  250.     XDEF    _log10
  251. _log10:
  252.     pea    _LVOSPLog10
  253.     jmp    .fpdo
  254.  
  255.     END
  256.