/
/
/	S  I  N
/	-  -  -
/
/SUBROUTINE	SIN(X)
/
/ VERSION 5A 4-27-77  PT
/
	SECT	SIN
	JA	#SIN
	EXTERN	#ARGER
SINER,	TRAP4	#ARGER
	TEXT	+SIN   +
SINXR,	SETX	XRSIN
	SETB	BPSIN
BPSIN,	F 0.0
XRSIN,	F 0.0
SIN1,	F 0.0
SIN2,	F 0.0
F1SIN,	F 1.
FPI2SN,	1		/PI DIVIDED BY 2
	3110
	3755
FPISIN,	2		/PI
	3110
	3755
F2PISN,	3		/TWO PI
	3110
	3755
	ORG	10*3+BPSIN
	FNOP
	JA 	SINXR
	0
SINRTN,	JA	.
/
SINC9,	7764
	2501
	7015
/
SINC7,	7771
	5464
	5515
/
SINC5,	7775
	2431
	5362
/
SINC3,	0000
	5325
	0414
/
SINTST,	7770
	2000
	0000
	BASE	0
#SIN,	STARTD
	FLDA	10*3
	FSTA	SINRTN
	FLDA	0
	SETX	XRSIN
	SETB	BPSIN
	BASE	BPSIN
	LDX	1,1	
	FSTA	BPSIN
	FLDA%	BPSIN,1  /ADDR OF X
	FSTA	BPSIN
	STARTF
	FLDA%	BPSIN	/GET X
	LDX	-1,0		/SET SIGN TO POSITIVE.
	JGT	SINMOD		/IF POSITIVE BYPASS FUDGE.
	JEQ	SINRTN		/IF ZERO EXIT.
	FNEG			/NEGATIVE. NEGATE AC. SIN(-X)=-SIN(X)
	LDX	0,0		/SET SIGN TO MINUS.
SINMOD,	JAL	SINER		/IF SIGN CAN T INT, THEN ERROR.
	FDIV	F2PISN		/REDUCE TO BELOW TWO PI.
	FSTA	SIN1		/SAVE IN A TEMP.
	ALN	0
	FNORM			/INTERGIZE IT.
	FNEG
	FADD	SIN1		/RECALL NUMBER. AC NOW <0
	FMUL	F2PISN		/NOW MULTIPLY BACK.
	FSTA	SIN2		/AND SAVE AWAY.
	FSUB	FPISIN		/SUBTRACT OFF PI.
	JLT	SINP		/LESS THEN PI.
	FSTA	SIN2		/RESTORE AS 2.
	XTA	0		/INVERT THE SIGN.
	FNEG
	FSUB	F1SIN		/SIN(X-PI)=-SIN(X)
	ATX	0		/AND PUT BACK.
/
SINP,	FLDA	SIN2		/RECALL MAGIC GOODY.
	FSUB	FPI2SN		/TEST TO SEE IF X<PI/2
	JLT	SINPP		/YEP.
/
	FLDA	FPISIN		/SIN(X)=SIN(PI-X)
	FSUB	SIN2
	FSTA	SIN2		/AND STORE IT BACK.
/
SINPP,	FLDA	SIN2		/GET THE MAGIC NUMBER.
	FSUB	SINTST		/SEE IF ITS CLOSE TO AN EDGE
	JGT	SINPPP		/IT IS NOT
	FLDA	SIN2		/RECALL NUMBER IF TOO SMALE
	JXN	SINRTN,0		/EXIT IF SAME SIGN.
	FNEG			/ELSE NEGATE IT.
	JA	SINRTN
SINPPP,	FLDA	SIN2		/RECALL NUMBER TO BE WORKED ON.
	FDIV	FPI2SN		/DIVIDE BY PI OVER TWO.
	FSTA	SIN2		/AND STORE BACK.
	FMUL	SIN2		/MULTIPLY OUT.
	FSTA	SIN1
	FMUL	SINC9		/NOW DO THE STANDARD ITERATION.
	FADD	SINC7
	FMUL	SIN1
	FADD	SINC5
	FMUL	SIN1
	FADD	SINC3
	FMUL	SIN1
	FADD	FPI2SN		/ADD IN PI OVER 2
	FMUL	SIN2		/DO THE FINAL MULTIPLY.
	JXN	SINRTN,0		/SHALL WE NEGATE
	FNEG			/YEP
	JA	SINRTN		/AND RETURN.
