Google
 

Trailing-Edge - PDP-10 Archives - bb-v895a-bm_tops20_v41_2020_dist_2of2 - language-sources/pltmth.mac
There are 39 other files named pltmth.mac in the archive. Click here to see a list.
USES A MODIFIED TAYLOR SERIES TO CALCULATE 
;THE SINE OF THE NORMALIZED ARGUMENT.

;THE ROUTINES ARE CALLED IN THE FOLLOWING MANNER:
;	JSA	Q,SIN		(OR COS,SIND, OR COSD)
;	EXP	ARG
;THE ANSWER IS RETURNED IN ACCUMULATOR A

	IFE HILOW,<
	TWOSEG
	RELOC	400000>
A=0
B=1
C=2
SX=3
Q=16

	HELLO	(COSD,.)	;[235] ENTRY TO COSINE DEGREES ROUTINE.
	MOVE	B,@(Q)		;PICK UP THE ARG.
	FADR	B,CD1		;ADD 90 DEGREES.
	FDVR	B,SCD1		;CONVERT TO RADIANS.
	JFCL			;SUPPRESS ERROR MESSAGE FROM OVTRAP.
	JRST	S1		;ENTER SINE ROUTINE.

	HELLO	(SIND,.)	;[235] ENTRY TO SINE DEGREES ROUTINE.
	MOVE	B,@(Q)		;PICK UP THE ARG.
	FDVR	B,SCD1		;CONVERT TO RADIANS
	JFCL			;SUPPRESS ERROR MESSAGE ON UNDERFLOW.
	JRST	S1		;ENTER SINE ROUTINE.

	HELLO	(COS,.)		;[235] ENTRY TO COSINE RADIANS ROUTINE.
	MOVE	B,@(Q)		;PICK UP THE ARG.
	FADR	B,PIOT		;ADD PI/2.
	JRST	S1		;ENTER SINE ROUTINE.


	HELLO	(SIN,.)		;[235] ENTRY TO SINE RADIANS ROUTINE.
	MOVE	B,@(Q)		;PICK UP THE ARG.
S1:	SAVE	SX
	MOVEM	B,SX		;SAVE THE ARG.
	MOVMS	B		;GET ABS OF ARG.
	CAMG	B,SP2		;SIN(X)=X IF X<2^-9.
	JRST	S3A		;EXIT WITH ARG. IN A.
	SAVE	C
	FDV	B,PIOT		;DIVIDE X BY PI/2.
	CAMG	B,ONE		;IS X/(PI/2) < 1.0 ?
	JRST	S2		;YES,ARG IN 1ST QUADRANT ALREADY.
	MULI	B,400		;NO,SEPARATE FRACTION AND EXP.
	LSH	C,-202(B)	;GET X MODULO 2PI.
	TLZ	C,(1B0)		;SUPRESS ERROR MESSAGE FROM OVTRAP.
	MOVEI	B,200		;PREPARE FLOATING FRACTION.
	ROT	C,3		;SAVE THREE BITS TO DETERMINE QUADRANT.
	LSHC	B,33		;ARGUMENT NOW IN THE RANGE (-1,1).
	FAD	B,SP3		;NORMALIZE THE ARGUMENT.
	JUMPE	C,S2		;REDUCED TO 1ST QUAD IF BITS 000.
	TLCE	C,1000		;SUBTRACT 1.0 FROM ARG IF BITS ARE
	FSB	B,ONE		;001 OR 011.
	TLCE	C,3000		;CHECK FOR FIRST QUADRANT, 001.
	TLNN	C,3000		;CHECK FOR THIRD QUADRANT, 010.
	MOVNS	B		;001,010.
S2:	SKIPGE	SX		;CHECK SIGN OF ORIGINAL ARG.
	MOVNS	B		;SIN(-X)=-SIN(X).
	MOVEM	B,SX		;STORE REDUCED ARG.
	FMPR	B,B		;CALCULATE X^X
	MOVE	A,SC9		;GET 1ST CONSTANT.
	FMP	A,B		;MULTIPLY BY X^2
	FAD	A,SC7		;ADD IN NEXT CONSTANT.
	FMP	A,B		;MULTIPLY BY X^2.
	FAD	A,SC5		;ADD IN NEXT CONSTANT.
	FMP	A,B		;MULTIPLY BY X^2.
	FAD	A,SC3		;ADD IN NEXT CONSTANT.
	FMP	A,B		;MULTIPLY BY X^2.
	FAD	A,PIOT		;ADD IN LAST CONSTANT.
S2B:	FMPR	A,SX		;MULTIPLY BY X.
	RESTOR	C
	SKIPA	0
S3A:	MOVE	A,SX		;ANSWER IN X.
	RESTOR	SX
	GOODBY	(1)		;EXIT

SC3:	577265210372
SC5:	175506321276
SC7:	606315546346
SC9:	164475536722

SP2:	170000000000
SP3:	0
CD1:	90.0
SCD1:	206712273406
PIOT:	201622077325
ONE:	1.0
	END