home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / tahoe / math / Katanf.s < prev    next >
Encoding:
Text File  |  1991-05-04  |  5.1 KB  |  182 lines

  1. /*-
  2.  * Copyright (c) 1985 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * This code is derived from software contributed to Berkeley by
  6.  * Computer Consoles Inc.
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in the
  15.  *    documentation and/or other materials provided with the distribution.
  16.  * 3. All advertising materials mentioning features or use of this software
  17.  *    must display the following acknowledgement:
  18.  *    This product includes software developed by the University of
  19.  *    California, Berkeley and its contributors.
  20.  * 4. Neither the name of the University nor the names of its contributors
  21.  *    may be used to endorse or promote products derived from this software
  22.  *    without specific prior written permission.
  23.  *
  24.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34.  * SUCH DAMAGE.
  35.  *
  36.  *    @(#)Katanf.s    7.1 (Berkeley) 12/6/90
  37.  */
  38.  
  39. #include "../tahoe/SYS.h"
  40.  
  41.     .text
  42. ENTRY(Katanf, 0)
  43.     tstl    4(fp)            # if (arg > 0)
  44.     jleq    1f
  45.     pushl    20(fp)            # hfs
  46.     pushl    8(fp)
  47.     pushl    4(fp)
  48.     callf    $16,satan
  49.     ret                # return(satan(arg));
  50. 1:                    # else
  51.     pushl    20(fp)            # hfs
  52.     lnd    4(fp)
  53.     pushd
  54.     callf    $16,satan
  55.     lnf    r0
  56.     stf    r0
  57.     ret                # return(-satan(-arg));
  58.  
  59. ASENTRY(satan, R2|R3)
  60.     subl3    $60,fp,sp
  61.     cmpd2    4(fp),_sq2m1        # if (arg < sq2m1)
  62.     jgeq    1f
  63.     pushl    12(fp)            # hfs
  64.     pushl    8(fp)
  65.     pushl    4(fp)
  66.     callf    $16,xatan
  67.     ret                # return(xatan(arg));
  68. 1:
  69.     cmpd2    4(fp),_sq2p1        # else if (arg > sq2p1)
  70.     jgtr    9f
  71.     pushl    12(fp)            # hfs
  72.     ldd    one; pushd
  73.     ldd    4(fp); pushd
  74.     callf    $24,_Kaddd        # (arg+1.0)
  75.     pushl    12(fp)            # hfs of _Kdivd
  76.     pushl    r1
  77.     pushl    r0
  78.     pushl    12(fp)            # hfs
  79.     ldd    one; pushd
  80.     ldd    4(fp); pushd
  81.     callf    $24,_Ksubd        # (arg-1.0)
  82.     pushl    r1
  83.     pushl    r0
  84.     callf    $24,_Kdivd        # (arg-1.0)/(arg+1.0)
  85.     pushl    12(fp)            # hfs
  86.     pushl    r1
  87.     pushl    r0
  88.     callf    $16,xatan        # xatan((ag-1.0)/(arg+1.0))
  89.     pushl    12(fp)            # hfs
  90.     pushl    r1
  91.     pushl    r0
  92.     ldd    _pio4; pushd
  93.     callf    $24,_Kaddd
  94.     ldd    r0; cvdf; stf r0
  95.     ret                # return(pio4+xatan((xatan(...)));
  96.  
  97. 9:
  98.     pushl    12(fp)    
  99.     ldd    4(fp); pushd
  100.     ldd    one; pushd
  101.     callf    $24,_Kdivd        # (1.0/arg)
  102.     pushl    12(fp)            # hfs
  103.     ldd    r0; pushd
  104.     callf    $16,xatan
  105.                     # clrl    -60+4(fp)
  106.                     # movl    r0,-60(fp)
  107.     pushl    12(fp)            # hfs
  108.     ldd    r0; pushd
  109.     ldd    _pio2; pushd
  110.     callf    $24,_Ksubd
  111.     ldd    r0; cvdf; stf r0
  112.     ret
  113.  
  114. ASENTRY(xatan, 0)
  115.     subl3    $68,fp,sp
  116.     pushl    12(fp)            # hfs
  117.     ldd    4(fp); pushd; pushd
  118.     callf    $24,_Kmuld        # argsq = arg*arg;
  119.     ldd    r0
  120.     std    -60(fp)            # argsq
  121.     pushl    12(fp)            # hfs
  122.     pushd            
  123.     ldd    _p5; pushd
  124.     callf    $24,_Kmuld        # p5*argsq
  125.     pushl    12(fp)            # hfs
  126.     ldd    _p4; pushd            
  127.     ldd    r0; pushd
  128.     callf    $24,_Kaddd        # (p5*argsq+p4)
  129.     pushl    12(fp)            # hfs
  130.     ldd    -60(fp); pushd
  131.     ldd    r0; pushd
  132.     callf    $24,_Kmuld        # (p5*argsq+p4)*argsq
  133.     pushl    12(fp)            # hfs
  134.     ldd    _p3; pushd            
  135.     ldd    r0; pushd
  136.     callf    $24,_Kaddd        # ((p5*argsq+p4)*argsq+p3)
  137.     pushl    12(fp)            # hfs
  138.     ldd    -60(fp); pushd
  139.     ldd    r0; pushd
  140.     callf    $24,_Kmuld        # (..)*argsq
  141.     pushl    12(fp)            # hfs
  142.     ldd    _p2; pushd            
  143.     ldd    r0; pushd
  144.     callf    $24,_Kaddd        # (..)*argsq+p2)
  145.     pushl    12(fp)            # hfs
  146.     ldd    -60(fp); pushd
  147.     ldd    r0; pushd
  148.     callf    $24,_Kmuld        # ((..)*argsq+p2)*argsq
  149.     pushl    12(fp)            # hfs
  150.     ldd    _p1; pushd            
  151.     ldd    r0; pushd
  152.     callf    $24,_Kaddd        # ((..)*argsq+p2)*argsq+p1)
  153.     pushl    12(fp)            # hfs
  154.     ldd    -60(fp); pushd
  155.     ldd    r0; pushd
  156.     callf    $24,_Kmuld        # (..)*argsq
  157.     pushl    12(fp)            # hfs
  158.     ldd    _p0; pushd            
  159.     ldd    r0; pushd
  160.     callf    $24,_Kaddd        # ((..)*argsq+p1)*argsq+p0)
  161.     pushl    12(fp)            # hfs
  162.     ldd    4(fp); pushd
  163.     ldd    r0; pushd
  164.     callf    $24,_Kmuld        # (..)*arg
  165.     ldd    r0
  166.     std    -68(fp); cvdf; stf r0    # value
  167.     ret
  168.  
  169.     .data
  170.     .align    2
  171. _sq2p1:    .long    0x411A8279, 0x99FCEF31 # .double 2.414213562373095
  172. _sq2m1:    .long    0x3FD413CC, 0xCFE77990 # .double .41421356237309503
  173. _pio2:    .long    0x40C90FDA, 0xA22168C1 # .double 1.5707963267948966
  174. _pio4:    .long    0x40490FDA, 0xA22168C1 # .double .78539816339744829
  175. _p0:    .long    0x407FFFFF, 0xFD687A4B # .double .99999999939652999
  176. _p1:    .long    0xBFAAAAA2, 0x09F9DBF2 # .double -.3333330762079
  177. _p2:    .long    0x3F4CC820, 0x0670059B # .double .199982166665
  178. _p3:    .long    0xBF11D182, 0x6601878B # .double -.142400777317
  179. _p4:    .long    0x3ED88B47, 0x4EFC9AF9 # .double .10573440275
  180. _p5:    .long    0xBE772E4B, 0x0E689AEB # .double -.060346883
  181. one:    .long    0x40800000, 0x00000000 # .double 1
  182.