1: #
   2: # Copyright (c) 1980 Regents of the University of California.
   3: # All rights reserved.  The Berkeley software License Agreement
   4: # specifies the terms and conditions for redistribution.
   5: #
   6: #	@(#)atan.s	5.1 (Berkeley) 5/8/85
   7: #
   8: #
   9: # double atan(arg1); -pi/2 < atan < pi/2
  10: #double atan2(arg1,arg2); -pi< atan2<pi
  11: #double arg1,arg2
  12: #method: range reduction to [sqrt(2)-1,sqrt(2)+1]
  13: # followed by Hart&Cheney ARCTN 5076 D=17.55
  14: # J. F. Jarvis August 8, 1978
  15: .globl  _atan
  16: .globl  _atan2
  17: .text
  18: .align  1
  19: _atan:
  20:         .word   0x03c0
  21:         bispsw  $0xe0
  22:         movd    4(ap),r0
  23:         jgtr    a1
  24:         mnegd   r0,r0   # atan(arg1), arg1<0
  25:         bsbb    satan
  26:         mnegd   r0,r0
  27:         ret
  28: a1:     bsbb    satan   # atan(arg1), arg1>=0
  29:         ret
  30: #
  31: .align  1
  32: _atan2:
  33:         .word   0x03c0
  34:         bispsw  $0xe0
  35:         movd    4(ap),r0        # atan(arg1/arg2)
  36:         movd    12(ap),r2
  37:         addd3   r0,r2,r4
  38:         cmpd    r0,r4
  39:         jneq    b1
  40:         tstd    r0
  41:         jgeq    b2
  42:         mnegd   pio2,r0
  43:         ret
  44: b2:     movd    pio2,r0
  45:         ret
  46: #
  47: b1:     tstd    r2
  48:         jgeq    b3
  49:         divd2   r2,r0
  50:         jleq    b4
  51:         bsbb    satan   # arg1<0, arg2<0
  52:         subd2   pi,r0
  53:         ret
  54: b4:     mnegd   r0,r0   # arg1>0, arg2<0
  55:         bsbb    satan
  56:         subd3   r0,pi,r0
  57:         ret
  58: #
  59: b3:     divd2   r2,r0
  60:         jleq    b5
  61:         bsbb    satan   # arg1>0, arg2>0
  62:         ret
  63: b5:     mnegd   r0,r0   # arg1<0, arg2>0
  64:         bsbb    satan
  65:         mnegd   r0,r0
  66:         ret
  67: #
  68: .globl  satan
  69: satan:  # range reduction on positive arg(r0)
  70:         cmpd    r0,sq2m1
  71:         jgeq    c1
  72:         bsbb    xatan
  73:         rsb
  74: c1:     cmpd    r0,sq2p1
  75:         jleq    c2
  76:         divd3   r0,$0d1.0e+0,r0
  77:         bsbb    xatan
  78:         subd3   r0,pio2,r0
  79:         rsb
  80: c2:     addd3   $0d1.0e+0,r0,r2
  81:         subd2   $0d1.0e+0,r0
  82:         divd2   r2,r0
  83:         bsbb    xatan
  84:         addd2   pio4,r0
  85:         rsb
  86: #
  87: xatan:  # compute arctan(r0) for:sqrt(2)-1<r0<sqrt(2)+1
  88: # Hart&Cheney ARCTN 5076 is evaluated
  89:         movd    r0,r8
  90:         muld3   r0,r0,r6
  91:         polyd   r6,$4,pcoef
  92:         muld2   r0,r8
  93:         polyd   r6,$4,qcoef
  94:         divd3   r0,r8,r0
  95:         rsb
  96: .data
  97: .align  2
  98: pcoef:
  99:         .double 0d0.1589740288482307048e+0
 100:         .double 0d0.66605790170092626575e+1
 101:         .double 0d0.40969264832102256374e+2
 102:         .double 0d0.77477687719204208616e+2
 103:         .double 0d0.44541340059290680319e+2
 104: qcoef:
 105:         .double 0d1.0e+0
 106:         .double 0d0.15503977551421987525e+2
 107:         .double 0d0.62835930511032376833e+2
 108:         .double 0d0.92324801072300974840e+2
 109:         .double 0d0.44541340059290680444e+2
 110: pio4: .double  0d0.78539816339744830961e+0
 111: pio2: .double  0d1.57079632679489661923e+0
 112: sq2p1: .double 0d2.41421356237309504880e+0
 113: sq2m1: .double 0d0.41421356237309504880e+0
 114: pi: .double 0d3.14159265358979323846e+0

Defined functions

a1 defined in line 28; used 1 times
  • in line 23
b1 defined in line 47; used 1 times
  • in line 39
b2 defined in line 44; used 1 times
  • in line 41
b3 defined in line 59; used 1 times
  • in line 48
b4 defined in line 54; used 1 times
  • in line 50
b5 defined in line 63; used 1 times
  • in line 60
c1 defined in line 74; used 1 times
  • in line 71
c2 defined in line 80; used 1 times
  • in line 75
satan declared in line 68; defined in line 69; used 10 times
xatan defined in line 87; used 3 times

Defined variables

pcoef defined in line 98; used 1 times
  • in line 91
pi defined in line 114; used 2 times
pio2 defined in line 111; used 3 times
pio4 defined in line 110; used 1 times
  • in line 84
qcoef defined in line 104; used 1 times
  • in line 93
sq2m1 defined in line 113; used 1 times
  • in line 70
sq2p1 defined in line 112; used 1 times
  • in line 74
Last modified: 1985-05-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 546
Valid CSS Valid XHTML 1.0 Strict