Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/16/mat.mac
There is 1 other file named mat.mac in the archive. Click here to see a list.
	SEARCH	SIMMAC,SIMRPA
	SALL
	RTITLE	TAN
	MACINIT
	SUBTTL TAN - SINGLE PRECISION TANGENT ROUTINE

; REWRITE OF ATLAS EXTRACODE 1735

; METHOD:
;
; X = (N+Y)*PI/2, WHERE N IS AN INTEGER, AND -0.5 <= Y < 0.5
;
; IF N IS EVEN, TAN(X) = P(Y)/(1 - Y^2)
;
; IF N IS ODD, TAN(X) = -(1 - Y^2)/P(Y)
;
; WHERE P(Y) IS AN ODD POLYNOMIAL IN Y

; ON ENTRY:
; THE ADDRESS OF THE  ARGUMENT (X) IS IN 0(X16)
; THE LINK IS ON THE STACK
; ON EXIT, THE RESULT IS IN X0

	ENTRY TAN.



TAN.:	PROC
	SAVE	<X3,X4,X5>
	L	X0,@(X16)
	JUMPE	X0,L4		; QUICK EXIT FOR ZERO
	FMPR	X0,[
	XWD	200505,746034]	; MULTIPLY BY 2/PI
	MOVM	X2,X0		; ABS(X)/(PI/2)
	MOVEI	X1,1		; SET FLAG FOR EVEN N
	CAMGE	X2,[
	XWD	200400,000000]	; LESS THAN 0.5?
	JRST	L1		; YES - TAKE SHORT CUT
	FSBRI	X2,200400	; NO - SUBTRACT 0.5
	MULI	X2,400		; SEPARATE EXPONENT AND MANTISSA
	EXCH	X2,X3		; THINGS ARE NOW THE WRONG WAY ROUND
	MOVEI	X1,0
	CAIL	X3,233		; WILL SHIFT CAUSE LOSS OF MANTISSA?
	TDZA	X2,X2		; YES - SAVE A LOT OF WORK
	ASHC	X1,-200(X3)	; SHIFT OUT INTEGER PART
	ANDI	X1,1		; SET ODD/EVEN FLAG FOR N
	LSH	X2,-10
	TLO	X2,200000	; AND FIX UP NEW EXPONENT
	FSBRI	X2,200400	; SUBTRACT 0.5 TO GET Y
L1():	MOVE	X3,X2		; SAVE Y
	FMPR	X2,X2		; SAVE Y^2
	MOVEI	X5,3
	MOVE	X4,TAN7

L2():	FMPR	X4,X2
	FADR	X4,TAN6(X5)
	SOJGE	X5,L2
	FMPR	X4,X3		; FORM -P(Y)
	MOVN	X2,X2
	FADRI	X2,201400	; FORM 1 - Y^2
	JUMPN	X1,L3		; N ODD?
	EXCH	X4,X2		; YES - EXCHANGE OPERANDS
	MOVN	X0,X0		; AND INVERT ARGUMENT SIGN

L3():	FDVR	X4,X2		; FORM FINAL RESULT
	EXCH	X0,X4		; LOAD UP RESULT
	JUMPGE	X4,L4		; SHOULD IT BE NEGATIVE?
	MOVN	X0,X0		; YES - NEGATE IT

L4():	RETURN
	EPROC

TAN6:	XWD	201622,077325	; PI/2
	XWD	600342,340621	; PI/2*((PI/2)^2/3 - 1)
	XWD	604353,774024	; (PI/2)^3*((PI/2)^2*2/15 - 1/3)
	XWD	610120,631722	; (PI/2)^5*((PI/2)^2*17/315 - 2/15)
TAN7:	XWD	613217,113617	; (PI/2)^7*((PI/2)^2*62/2835 - 17/315)

	END