; math_acsc.asm ; ; Assembly language source for the arc cosecant ; function: include math.inc include aoalib.inc ; ACSC(x)- Computes the arccosecant of st(0) ; and leaves the result in st(0). ; Note: x cannot be a value in the range -1..+1. ; There must be at least two free registers ; for this function to operate properly. ; ; acsc(x) = Atan(Sign(x) / Sqrt(x * x - 1)) .code math_acsc proc fld st(0) ;For later use. ; Compute sqrt( x*x - 1 ) fld st(0) ;Two copies of x fmulp ;Compute x*x fld1 ; Compute x*x-1 fsubp fldz ;Test for x<=-1 fcomip st(0), st(1) jae badSqrt ; We now know that x > 1 fsqrt ; Compute sqrt(x*x-1) ; Now load -1 or +1 onto stack based on sign of ; original value (We know it's not 0): fldz fcomip st(0), st(2) ;Original x value fld1 jb itsPos1 fchs ;-1 itsPos1: fdivrp ; fld1 ; fpatan ; Compute atan of above. fstp st(1) ;Pop ST(1) ret badSqrt: fstp st(0) ;Remove (x*x-1) fstp st(0) ;Remove original X fld math_nan ;Put NaN on stack ret math_acsc endp end